protected function isTemplateNameSupported(string $templateName): bool
    {
        $templateNames = $this->getEnvironment()->getConfig()->get($this->templateConfigKey);

        if (!is_array($templateNames)) {
            return false;
        }

        foreach ($templateNames as $supported) {
            if ($templateName === $supported) {
                return true;
            }

            if (substr($supported, -1) === '*'
                && 0 == strcasecmp(substr($supported, 0, -1), substr($templateName, 0, (strlen($supported) - 1)))
            ) {
                return true;
            }
        }

        return false;
    }