public function getBundleTemplate(string $name, string $format = 'html.twig'): string
    {
        $templatePath = $name;

        $bundles = $this->kernel->getBundles();
        // if file from Controller::getTemplate() does not exist, search template in bundle views directory and return twig bundle path
        if (\is_array($bundles) && '.twig' === substr($format, -5)) {
            $pattern = $name.'.'.$format;

            foreach (array_reverse($bundles) as $key => $value) {
                $path = $this->kernel->locateResource("@$key");
                $finder = new Finder();
                $finder->in($path);
                $finder->files()->name($pattern);
                $twigKey = preg_replace('/Bundle$/', '', $key);

                foreach ($finder as $val) {
                    $explodurl = explode('Resources'.\DIRECTORY_SEPARATOR.'views'.\DIRECTORY_SEPARATOR, $val->getRelativePathname());
                    $string = end($explodurl);
                    $templatePath = "@$twigKey/$string";

                    break 2;
                }
            }
        }

        return $templatePath;
    }