mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-06-26 06:29:24 +02:00
FIX Convert slashes in paths when getting list of classes for file/folder
This is to support the mechanism working on all operating systems where Windows may produce a mix of forward and backward slashes in some paths. For working with the files it may not be a problem, but for exact string comparison the path delimiters need to be unified.
This commit is contained in:
parent
54fc4ee9d2
commit
6585d499f5
|
@ -301,14 +301,14 @@ class ClassInfo
|
||||||
*/
|
*/
|
||||||
public static function classes_for_file($filePath)
|
public static function classes_for_file($filePath)
|
||||||
{
|
{
|
||||||
$absFilePath = Director::getAbsFile($filePath);
|
$absFilePath = Convert::slashes(Director::getAbsFile($filePath));
|
||||||
$classManifest = ClassLoader::inst()->getManifest();
|
$classManifest = ClassLoader::inst()->getManifest();
|
||||||
$classes = $classManifest->getClasses();
|
$classes = $classManifest->getClasses();
|
||||||
$classNames = $classManifest->getClassNames();
|
$classNames = $classManifest->getClassNames();
|
||||||
|
|
||||||
$matchedClasses = [];
|
$matchedClasses = [];
|
||||||
foreach ($classes as $lowerClass => $compareFilePath) {
|
foreach ($classes as $lowerClass => $compareFilePath) {
|
||||||
if (strcasecmp($absFilePath ?? '', $compareFilePath ?? '') === 0) {
|
if (strcasecmp($absFilePath, Convert::slashes($compareFilePath ?? '')) === 0) {
|
||||||
$matchedClasses[$lowerClass] = $classNames[$lowerClass];
|
$matchedClasses[$lowerClass] = $classNames[$lowerClass];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,14 +324,14 @@ class ClassInfo
|
||||||
*/
|
*/
|
||||||
public static function classes_for_folder($folderPath)
|
public static function classes_for_folder($folderPath)
|
||||||
{
|
{
|
||||||
$absFolderPath = Director::getAbsFile($folderPath);
|
$absFolderPath = Convert::slashes(Director::getAbsFile($folderPath));
|
||||||
$classManifest = ClassLoader::inst()->getManifest();
|
$classManifest = ClassLoader::inst()->getManifest();
|
||||||
$classes = $classManifest->getClasses();
|
$classes = $classManifest->getClasses();
|
||||||
$classNames = $classManifest->getClassNames();
|
$classNames = $classManifest->getClassNames();
|
||||||
|
|
||||||
$matchedClasses = [];
|
$matchedClasses = [];
|
||||||
foreach ($classes as $lowerClass => $compareFilePath) {
|
foreach ($classes as $lowerClass => $compareFilePath) {
|
||||||
if (stripos($compareFilePath ?? '', $absFolderPath ?? '') === 0) {
|
if (stripos(Convert::slashes($compareFilePath ?? ''), $absFolderPath) === 0) {
|
||||||
$matchedClasses[$lowerClass] = $classNames[$lowerClass];
|
$matchedClasses[$lowerClass] = $classNames[$lowerClass];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user