Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this do?
Allows a default view namespace to be set in the
App
class, making it easier to override views, particularly template views. It will first assume that a relative view path, i.e. one that has the format of::path:to:view
, uses the default view namespace. If the view cannot be found, it will revert to its current behaviour - it will check the most recently used namespace that has been declared within a view and try and find it that way. If it still cannot find it, it will throw an exception as it does currently.How should this be manually tested?
In a Mothership project, edit the
App.php
file so the class hasgetDefaultViewNamespace()
method, which returns the view namespace of the main site codebase, e.g.:Then look for a view override (there are plenty in Ecommerce' checkout) and move it to the main view directory of the project (for instance, you could move
/view/Message:Mothership:Ecommerce/checkout/checkout-layout.html.twig
to/app/general/resources/view/checkout/checkout-layout.html.twig
). Doing this will still not work, as this PR only sets up the capability of overriding views in this way. You will need to edit a view that references this view, for instance thestage-1-review.html.twig
view in Ecommerce, and remove the namespace from theextends
statement, so instead of having:you will have
This will automatically look for a view with a reference of
Mothership:Site::checkout:checkout-layout
, which can be found in theresources/views/checkout
directory of the main project.You should then check that it does not error if you remove this view, but rather renders the default view in Ecommerce (the one that has no styling)
In a Mothership module, change one of the view extends to use a relative path reference.
This change also works with asset paths. If you add a 'test.js' file in both a module and in the site itself, and link to it in a view within the module using
@::assets:js:test.js
, it should first look within the declared namespace for the asset file, and if it can't find it, default to the namespace of the module it is called from.Related PRs / Issues / Resources?
Anything else to add? (Screenshots, background context, etc)