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

Add export function to include parent theme templates into the purge content #1

Open
Vinai opened this issue Jul 1, 2022 · 0 comments

Comments

@Vinai
Copy link
Contributor

Vinai commented Jul 1, 2022

It would be useful to add a function to the library that adds templates from parent themes to the purge content fallback, if they are not overridden.

There is a non-generic example for this in the Advanced Purge Config docs.

The function for this library should determine the theme parent hierarchy up until hyva-themes/magento2-reset-theme.

Here is a draft for the algorithm:

Assuming the theme hierarchy
themeA => themeB => magento2-default-theme => magento2-reset-theme

The desired output is an array of template files to use as the (purge) content configuration.

Initially the list of files is empty [].

It should first build a list of all template files in the reset-theme child magento2-default-theme.

Then, it checks the next theme in the hierarchy, which is themeB.
For any file in themeB that is also present in the magento2-default-theme, the file in themeB should replace the file from magento2-default-theme in the result list.
Any new file in themeB that is not also in magento-default-theme should be added to the list.

The result at this time is a list of all template files in themeB and magento2-default-theme following the Magento theme fallback.

Then, it checks the next theme in the hierarchy, which is themeA.
The same process that already was done for themeB now is done for themeA.
For any file in themeA that is also present in themeB or magento2-default-theme, the file in themeA should replace the file from the parent themes in the result list.
Any new file in themeA that is not present in one of the parent themes should be added to the list.

The final result is an array of all template files in the theme hierarchy according to the Magento theme fallback.

Ideally, the file types to check should be configurable, e.g.
/*/templates/**/*.phtml would check for any templates in parent themes, /*/layout/**/*.xml would check for layouts etc - you get the idea.

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