Call postLoad() hook by bundle #8 - #9
Open
simonbaese wants to merge 1 commit into
Open
simonbaese wants to merge 1 commit into
simonbaese wants to merge 1 commit into
Conversation
Author
|
@amcgowanca Glad if you could review this pull request. |
amcgowanca
requested changes
Nov 5, 2018
| if (isset($this->bundleKey)) { | ||
| $entities_by_bundle = []; | ||
| foreach ($entities as $entity) { | ||
| $entities_by_bundle[$entity->get($this->bundleKey)->getString()][] = $entity; |
Owner
There was a problem hiding this comment.
@simonbaese Could we not use something like just $entity->bundle()?
Author
There was a problem hiding this comment.
@amcgowanca I was not really sure because you were checking for the bundleKey throughout the code. The method bundle() specifically looks for the value by the key 'bundle' in the entity (see ContentEntityBase) and as it is public it could also be overwritten.
Contributor
|
I need something like this too. The patch I created before seeing this is at #14 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Looking to resolve #8 with this pull request. I modified the suggested code because the given entities might have different bundles. Thus we have to get the entity classes for each entity and call the respective hook defined by the class.
Maybe we should add another check if the bundle is set for the entity in line 130. But I dont know if there is a scenario were the postLoad() hook is called for bundled and "not"-bundled entities at the same time.