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

[Feature] Twig Block versioning #167

Open
shyim opened this issue Jan 8, 2024 · 0 comments
Open

[Feature] Twig Block versioning #167

shyim opened this issue Jan 8, 2024 · 0 comments

Comments

@shyim
Copy link
Collaborator

shyim commented Jan 8, 2024

Problem

It's hard to keep Twig blocks up to date after Shopware update or plugin update, when the extended block has been changed. This is true for complete replacements/before and after changes.

So when developers update Shopware or a plugin, where they changed blocks, they manually check every block they overwritten if the content is still the same, or they check the styling of the page.

Both options are time-intensive:

Solution

A solution for this problem could be to add versioning to the Twig blocks

{% sw_extends '@Storefront/....' %}

{# shopware-block: <sha-hash-of-upstream-template>#<shopware-version-of-the-creation> #}
{% block component_fooo %}

{% endblock %}

This PhpStorm Plugin can read that comment and differentiate the generated hash from the current hash. The hash is generated from the original template. When you are on the same Shopware version, they match.
If not, we can highlight the block in yellow and say something changed in this block in the upstream template.

To simplify the lookup for changes, we can add an Intention (CMD/Control + Enter) to show a git diff between the previous and the current version of the block using the version added in the comment. So the user can directly see what has been changed.
After they made the changes, they can run a second Intention (CMD/Control + Enter) to update the hash to the newest version and go to the next block.

Migration

We can add a simple Intention to blocks to add the versioning if it's missing from the current value.

Configuration

We should add a config for opt-in for this feature for any theme/plugin/app. Some plugins are intentionally made for a lot of Shopware versions like Store Plugins, where this feature may not wanted.

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

No branches or pull requests

1 participant