Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Coming from #1911080: Replace menu node form additions with entity reference field, I think this little helper function could be split as a small subtask.
Comment | File | Size | Author |
---|---|---|---|
#5 | entity-reference-util-1924774.5.interdiff.txt | 3.88 KB | larowlan |
#5 | entity-reference-util-1924774.5.patch | 4 KB | larowlan |
#1 | 1924774.patch | 2.58 KB | amateescu |
Comments
Comment #1
amateescu CreditAttribution: amateescu commentedHere's how I think it should look like.
Comment #2
sunAt minimum, the $entity_type and $bundle parameters should come first, I think.
Can't comment on the architectural idea of this right now, as I'm not up to speed on entity reference field yet.
Comment #3
amitaibuThis can be handy, there are many places in the tests we can use.
Indeed, lets move $entity_type and $bundle before. Also, maybe we
$taget_entity_type
=>$target_type
When will we have something like this?
Comment #4
larowlanThis can happen if someone uses an install profile that enables both entity_reference and creates a field in the same process from memory, commerce_* modules uses it fairly consistently
Comment #5
larowlanThis patch re-orders the params as per #2 but leaves $target_entity_type intact, I think $target_type is not as self-evident as $target_entity_type.
Also refactors Drupal\entity_reference\Tests\EntityReferenceItemTest::setUp() to use this utility so we have some test coverage.
Comment #6
amitaibuSeems ok.
Comment #7
chx CreditAttribution: chx commentedI am leaving this at RTBC 'cos it's fine as it is. Still, perhaps it could be even better? Should this leave in .install as it's extremely likely to be used install time? Orshould this live in a class with one named setter for each argument like
or is that overkill?
Comment #8
webchickHm. Don't think overkill, but (at least in the Old World Order™) it's more common to have wrapper functions for this type of thing than classes you need to dig through 27 directories to find. :)
Committed and pushed to 8.x. Thanks!
Comment #9
ParisLiakos CreditAttribution: ParisLiakos commentedThis is very useful, i am already using it over at #15266: Replace aggregator category system with taxonomy but i wish there was a way to pass widget info..right now it uses the default autocomplete one, so i have to load back the instance to change the widget:( still though, a lot less lines of code i have to write:)
Comment #10
amateescu CreditAttribution: amateescu commentedThat part will be solved by a (hopefully) future version of
entity_get_form()
, similar toentity_get_display()
, basically form modes :)