Compare commits

..

8 Commits

Author SHA1 Message Date
Guy Sartorelli
0307fa6cb0
Merge 2bea868994 into b985f052cf 2024-09-25 00:18:58 +00:00
Guy Sartorelli
2bea868994
ENH Use standardised BackURL instead of non-standard returnURL 2024-09-25 12:18:52 +12:00
Guy Sartorelli
b985f052cf
Merge branch '5' into 6 2024-09-24 14:04:46 +12:00
Guy Sartorelli
df82162291
Merge pull request #3008 from creative-commoners/pulls/5/framework-version
DEP Increase minimum version of silverstripe/framework
2024-09-24 09:39:50 +12:00
Steve Boyd
e2ca1cb77d DEP Increase minimum version of silverstripe/framework 2024-09-23 15:15:02 +12:00
Guy Sartorelli
4b3e1f09bf
ENH Don't use deprecated method (#3006) 2024-09-19 14:06:39 +12:00
Guy Sartorelli
24bb95d3bf
Merge pull request #3004 from sunnysideup/patch-21
FIX: put current page at top of ClassName dropdown (was broken)
2024-09-18 09:30:05 +12:00
Nicolaas @ Tappy @ Sunny Side Up
d8748ff5f9 FIX: return right order for getClassDropdown method 2024-09-15 17:06:28 +12:00
2 changed files with 22 additions and 15 deletions

View File

@ -2747,8 +2747,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
protected function getClassDropdown()
{
$classes = SiteTree::page_type_classes();
$currentClass = null;
$result = [];
foreach ($classes as $class) {
$instance = singleton($class);
@ -2774,20 +2772,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
}
}
$pageTypeName = $instance->i18n_singular_name();
$currentClass = $class;
$result[$class] = $pageTypeName;
$result[$class] = $instance->i18n_singular_name();
}
// sort alphabetically, and put current on top
// Sort alphabetically, and put current on top
asort($result);
if ($currentClass) {
$currentPageTypeName = $result[$currentClass];
unset($result[$currentClass]);
$result = array_reverse($result ?? []);
$result[$currentClass] = $currentPageTypeName;
$result = array_reverse($result ?? []);
if (isset($result[$this->ClassName])) {
$currentPageTypeName = $result[$this->ClassName];
unset($result[$this->ClassName]);
$result = [$this->ClassName => $currentPageTypeName] + $result;
}
return $result;

View File

@ -1272,7 +1272,7 @@ class SiteTreeTest extends SapphireTest
#[DataProvider('allowedChildrenProvider')]
public function testAllowedChildren($className, $expected, $assertionMessage)
{
$class = new $className;
$class = new $className();
$this->assertEquals($expected, $class->allowedChildren(), $assertionMessage);
}
@ -1351,6 +1351,9 @@ class SiteTreeTest extends SapphireTest
);
}
/**
* @return void
*/
public function testClassDropdown()
{
$sitetree = new SiteTree();
@ -1372,7 +1375,18 @@ class SiteTreeTest extends SapphireTest
$this->assertArrayNotHasKey(SiteTreeTest_NotRoot::class, $method->invoke($rootPage));
$this->assertArrayHasKey(SiteTreeTest_NotRoot::class, $method->invoke($nonRootPage));
foreach ([SiteTreeTest_ClassA::class, SiteTreeTest_ClassB::class] as $className) {
$otherPage = new $className();
$otherPage->write();
$result = $method->invoke(object: $otherPage);
$this->assertEquals(array_key_first($result), $className);
// remove the first element as this is not alphabetical
array_shift($result);
// create a sorted array
$resultSorted = $result;
asort($resultSorted);
$this->assertEquals($result, $resultSorted);
}
Security::setCurrentUser(null);
}