protected static function discoverExtensionComponentDirectory($directory)
    {
        $components        = [];
        $directoryIterator = new \RecursiveDirectoryIterator($directory);
        $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator);
        $regexIterator     = new \RegexIterator(
            $recursiveIterator,
            PATH_SEPARATOR.'^'.preg_quote($directory.DIRECTORY_SEPARATOR).'.+Component\.php$'.PATH_SEPARATOR,
            \RecursiveRegexIterator::GET_MATCH
        );

        // Run through all potential component files
        foreach ($regexIterator as $component) {
            // Run through all classes declared in the file
            foreach (self::discoverClassesInFile(file_get_contents($component[0])) as $className) {
                // Test if this is a component class
                $classReflection = new \ReflectionClass($className);
                if ($classReflection->implementsInterface(ComponentInterface::class)) {
                    $components[] = self::addLocalConfiguration($component[0], self::discoverComponent($className));
                }
            }
        }

        return $components;
    }