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

Update add-custom-controller.md #1168

Merged
merged 1 commit into from
Nov 9, 2023
Merged

Conversation

daslicht
Copy link
Contributor

@daslicht daslicht commented Nov 6, 2023

added missing method="setTwig" call

added missing ```method="setTwig">``` call
@Isengo1989
Copy link
Collaborator

For future reference

Storefront Controller need to have Twig injected in future versions

The twig service will be private with upcoming Symfony 6.0. To resolve this deprecation, a new method setTwig was added to the StorefrontController.
All controllers which extends from StorefrontController need to call this method in the dependency injection definition file (services.xml) to set the Twig instance.
The controllers will work like before until the Symfony 6.0 update will be done, but they will create a deprecation message on each usage.
Below is an example how to add a method call for the service using the XML definition.

Before

<service id="Shopware\Storefront\Controller\AccountPaymentController">
    <call method="setContainer">
        <argument type="service" id="service_container"/>
    </call>
</service>

After

<service id="Shopware\Storefront\Controller\AccountPaymentController">
    <call method="setContainer">
        <argument type="service" id="service_container"/>
    </call>
    <call method="setTwig">
        <argument type="service" id="twig"/>
    </call>
</service>

@Isengo1989
Copy link
Collaborator

@daslicht could you add it in # Add Dynamic Content via AJAX Calls as well, so we got it covered for the future 🙂

Copy link
Collaborator

@Isengo1989 Isengo1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add info to other example

@daslicht
Copy link
Contributor Author

daslicht commented Nov 9, 2023

Please add info to other example

created pull request here #1178

@Isengo1989 Isengo1989 merged commit 95c58e6 into shopware:main Nov 9, 2023
@Isengo1989
Copy link
Collaborator

@daslicht ok, that work's as well 🙂

Thanks for the PR 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants