Skip to content

dynamic resolvers + theme code resolver#69

Merged
therouv merged 5 commits into
mainfrom
feature/add-theme-code-resolver
Mar 10, 2023
Merged

dynamic resolvers + theme code resolver#69
therouv merged 5 commits into
mainfrom
feature/add-theme-code-resolver

Conversation

@therouv
Copy link
Copy Markdown
Contributor

@therouv therouv commented Feb 28, 2023

Please make sure these boxes are checked before submitting your PR - thank you!

  • Pull request is based against main branch
  • README.md reflects changes (if applicable)
  • New files contain a license header

Changes

Dynamic Resolvers

Previously, the environment variable resolver was the only available resolver. This was not very flexible if one might want to add additional resolvers (either to this module or project-specific resolvers).

The ImportProcessor now accepts an array with all resolvers that have been defined in di.xml.

Each resolver must implement a supports method which checks whether a value or a config path matches certain criteria. If yes, the resolver will be called.

If a value can not be resolved and should be skipped in the process, a UnresolveableValueException exception must be thrown by the resolver.

Environment Variable Resolver

The prompting for missing environment variables has been moved to the resolver and is no longer part of the ImportProcessor.

Theme Code Resolver (NEW)

When assigning a theme to a website/store, Magento internally saves the ID of the selected theme in the config database table (path design/theme/theme_id). Theme IDs might change but also hard-coding them in a config file is not recommended.

Previously, there was no way to configure this value using this module. Now, you can use a specific syntax for theme codes in the configuration files. This is done with the syntax %theme(path)% (after discussing with some people, I opted for a similar syntax like we already use for environment variables).

For example, this might be the content of your config file:

design/theme/theme_id:
  default:
    0: '%theme(frontend/Vendor/theme)%'

The placeholder requires the theme path that is defined as component name in the registration.php file of a Magento theme, e.g. frontend/Vendor/theme (never use just Vendor/theme!).

The module will check if this theme is available in Magento. If yes, the module will write the ID of the theme to the core_config_data table. If no theme with that path can be found, an UnresolveableValueException exception will be thrown.

@therouv therouv marked this pull request as ready for review March 1, 2023 12:56
@therouv therouv merged commit c0a82c6 into main Mar 10, 2023
@therouv therouv deleted the feature/add-theme-code-resolver branch March 10, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant