diff --git a/includes/services/Performer.php b/includes/services/Performer.php index 13ebdc716..84fcd192d 100644 --- a/includes/services/Performer.php +++ b/includes/services/Performer.php @@ -121,7 +121,7 @@ public function createPerformable(array $object, array &$vars, &$output) /* extract extension name from path to allow namespace */ if (preg_match('/(?:tools[\\\\\\/]([A-Za-z0-9_\\-]+)|(custom))[\\\\\/][a-zA-Z0-9_\\\\\/\\-]+.php$/', $object['filePath'], $matches)) { $extensionName = empty($matches[1]) ? $matches[2]:$matches[1]; - $classNameWithNamespace = "YesWiki\\".ucfirst(strtolower($extensionName))."\\".$object['baseName']; + $classNameWithNamespace = "YesWiki\\".StringUtilService::folderToNamespace($extensionName)."\\".$object['baseName']; if (class_exists($classNameWithNamespace)) { $className = $classNameWithNamespace; } diff --git a/includes/services/StringUtilService.php b/includes/services/StringUtilService.php new file mode 100644 index 000000000..4cce95902 --- /dev/null +++ b/includes/services/StringUtilService.php @@ -0,0 +1,14 @@ +assertEquals( + $expected, + StringUtilService::folderToNamespace($input), + 'Unable to convert : ' . $input + ); + } + + public function folderToNamespaceProvider() + { + return [ + ['', ''], + ['.', ''], + ['foo', 'Foo'], + ['Foo', 'Foo'], + ['foo1', 'Foo1'], + ['foO', 'Foo'], + ['foo.bar', 'FooBar'], + ['foo-bar', 'FooBar'], + ['foo_bar', 'FooBar'], + ['foo~bar', 'FooBar'], + ]; + } +}