diff --git a/src/Core/Manifest/ClassManifest.php b/src/Core/Manifest/ClassManifest.php index 9d406620d..0e2887635 100644 --- a/src/Core/Manifest/ClassManifest.php +++ b/src/Core/Manifest/ClassManifest.php @@ -650,6 +650,11 @@ class ClassManifest } $this->children[$lowerAncestor][$lowerClassName] = $className; } + + // If the class extends a core class, add class to roots + if (strpos($ancestor, 'SilverStripe\\Control') === 0) { + $this->roots[$lowerAncestor] = $ancestor; + } } else { $this->roots[$lowerClassName] = $className; } diff --git a/tests/php/Core/ClassInfoTest.php b/tests/php/Core/ClassInfoTest.php index a1d353483..7528c3f36 100644 --- a/tests/php/Core/ClassInfoTest.php +++ b/tests/php/Core/ClassInfoTest.php @@ -87,6 +87,14 @@ class ClassInfoTest extends SapphireTest $subclassesWithoutBase, ClassInfo::subclassesFor('silverstripe\\core\\tests\\classinfotest\\baseclass', false) ); + + // Check that core classes are present (eg: Email subclasses) + $emailClasses = ClassInfo::subclassesFor(\SilverStripe\Control\Email\Email::class); + $this->assertArrayHasKey( + 'silverstripe\\control\\tests\\email\\emailtest\\emailsubclass', + $emailClasses, + 'It contains : ' . json_encode($emailClasses) + ); } public function testClassName()