{% sw_extends '@Storefront/storefront/utilities/icon.html.twig' %}
{% block utilities_icon %}
{% set styles = [ size, color, rotation, flip, class ] %}
{% if pack is not defined %}
{% set pack = 'default' %}
{% endif %}
{% if namespace is not defined %}
{% set namespace = 'Storefront' %}
{% endif %}
{% if theme_config('wyn-iconset') %}
{% set iconPath = theme_config('wyn-iconset') %}
{% else %}
{% set iconPath = 'default' %}
{% endif %}
{% set wynNamespace = 'WynTheme' %}
{% set wynNamespaceExtension = 'WynCustomerTheme' %}
{# First try to find the icon in @WynCustomerTheme/app/storefront/dist/assets/icon/[icon-set]/[name].svg #}
{% if source('@' ~ wynNamespaceExtension ~ '/app/storefront/dist/assets/icon/' ~ iconPath ~'/'~ name ~'.svg', ignore_missing = true) %}
{% set pack = iconPath %}
{% set namespace = wynNamespaceExtension %}
{# No matching icon found in WynCustomerTheme, try WynTheme, otherwise try default Shopware icons #}
{% elseif source('@' ~ wynNamespace ~ '/app/storefront/dist/assets/icon/' ~ iconPath ~'/'~ name ~'.svg', ignore_missing = true) %}
{% set pack = iconPath %}
{% set namespace = wynNamespace %}
{% endif %}
<span
class="icon icon-{{ name }}{% for entry in styles %}{% if entry != "" %} icon-{{ entry }}{% endif %}{% endfor %}"
{% if slotAttr %}slot="{{ slotAttr }}"{% endif %}
>
{# source() inserts the file contents, i.e. the SVG code of the icon #}
{{ source('@' ~ namespace ~ '/app/storefront/dist/assets/icon/' ~ pack ~'/'~ name ~'.svg', ignore_missing = true) }}
</span>
{% endblock %}