-
Notifications
You must be signed in to change notification settings - Fork 7
Description
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.