private function fetchTemplatesFromResourceDirectories($templateBaseName)
    {
        $allTemplates = [];
        $themeName    = $this->getNoThemeMessage();
        // Add the module templates folders if they exist.
        foreach ($this->resourceDirs as $resourceDir) {
            $allTemplates = array_replace_recursive(
                $allTemplates,
                $this->getTemplatesForBaseFrom($templateBaseName, $resourceDir . '/templates', $themeName)
            );
        }

        return $allTemplates;
    }