Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "SwTwigFunction" not found when using macro with return #70

Open
david-strauch opened this issue Jan 8, 2025 · 1 comment
Open
Labels
kind/bug Something isn't working

Comments

@david-strauch
Copy link

PHP Version

8.3

Shopware Version

6.6.9.0

Plugin Version

1.0.3

Actual behaviour

Hi, we are using a twig-macro in our themes to provide IDs for the searchMedia Twig-function.

Example:

{% sw_extends '@Storefront/storefront/layout/navigation/navigation.html.twig' %}

{% block layout_main_navigation %}
    {% set iconMediaIds = [] %}
    {% set iconMediaIds = _self.recursiveCollectIconMediaIds(page.header.navigation.tree, iconMediaIds) %}
    {% set iconMediaCollection = searchMedia(iconMediaIds, context.context) %}

    {% macro recursiveCollectIconMediaIds(treeItems, iconMediaIds) %}
        {% for treeItem in treeItems %}
            {% set iconMediaId = treeItem.category.translated.customFields.custom_category_image %}
            {% set iconMediaIds = iconMediaId ? iconMediaIds|merge([iconMediaId]) : iconMediaIds %}

            {# recoursion #}
            {% if treeItem.children is defined and treeItem.children|length > 0 %}
                {% set iconMediaIds = _self.recursiveCollectIconMediaIds(treeItem.children, iconMediaIds) %}
            {% endif %}
        {% endfor %}

        {% return iconMediaIds %}
    {% endmacro %}

    {% dump(iconMediaIds) %}

    {{ parent() }}
{% endblock %}

After installing and activating the FroshDevelopmentHelper plugin, we got this Error

Image
Image

We tried to remove the return, because of the scope of iconMediaIds, but these leads to another error:
Image

Reminds me a lot of issue shopware/shopware#3680

Expected behaviour

Using return in a macro should not lead to error Class "SwTwigFunction" not found

Steps to Reproduce?

  1. Create a twig view with a macro like my example above
  2. Install and Activate FroshDevelopmentHelper
@david-strauch david-strauch added the kind/bug Something isn't working label Jan 8, 2025
@lruozzi9
Copy link

After upgrading to 6.6.10.0 I get this error on dev env with enabled plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants