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.
Summary
Note: This was already approved and merged in
emulsify_twig
as part of PR-61The changes didn't make their way into
emulsify_tools
.The fix includes a check of
$context['attributes']
to see if it exists and if not, create anew Attribute()
. If it did exist in the first place, a secondary check makes sure that if it's an array, to create an Attribute object from that array.This fix is based on issues reported on the Drupal.org issue queue:
Fixes
$context['attributes']
to see if it exists and if not, create anew Attribute()
.$context['attributes']
did exist in the first place, a secondary check makes sure that if it's an array, to create anAttribute
object from that array.Explain the motivation for making this change. What existing problem does the pull request solve?
Sometimes the
$context
variable does not supply attributes as per https://www.drupal.org/project/emulsify_twig/issues/3160391Because of this, there are times when it was assumed to be an
Attribute
object and therefore would throw errors as per https://www.drupal.org/project/emulsify_twig/issues/3210140Finally, there could be times when the
$context['attributes']
is an array. If so, it should be converted to anAttribute
object based on that array as per https://www.drupal.org/project/emulsify_twig/issues/3302662Documentation update (required)
None - this is an internal change only.
How to review this pull request
twig_render_template
function as was mentioned in https://www.drupal.org/project/emulsify_twig/issues/3210140. This can be replicated with updated code:The output above doesn't necessarily need to be actually rendered, just this call did produce the error prior to this fix.
bem
andadd_attributes
in use, inside views, views with Ajax pagers, and search results pages - essentially places that aren't "typical" view modes.Closing issues
Closes Drupal.org issues listed above.