Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
migration system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
25 Apr 2017 at 20:26 UTC
Updated:
12 May 2017 at 20:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnAs a starting place, look at the entity_lookup process plugin in migrate_plus. The difference is we'd like make this much more explicit and have less magic.
Comment #3
vasi commentedHere's a first stab at this, if someone wants to take it farther.
TODO:
* Better docs: What should transform() return? True/false? The entity/null?
* Write tests
Comment #4
rakesh.gectcrThanks @Vasi,
was talking @heddn
Let me try to roll the patch ASAP
Comment #5
rakesh.gectcrUploaded the first patch, Ones the plugin is reviewed and finalised, will write the test as well . :)
Comment #6
rakesh.gectcrComment #7
phenaproximaThis needs to implement ContainerFactoryPluginInterface.
Should be just "The plugin ID".
This needs to use // comment style, not /* */ style.
We don't want to return a full entity here -- just an indication of whether it exists. So this should be something like this:
return $this->storage->load($value) instanceof EntityInterfaceComment #8
heddn#7.4: Is it generally more useful to return FALSE | entity id? Rather than FALSE | TRUE?
Comment #9
rakesh.gectcrWell, I checked with mike, He is also in the same page of returning Entity_id, so rolled out with returning entity_id | FALSE. and done all the #4
Comment #10
peatonI'm going to work on this!
Comment #11
phenaproximaLooking better and better. I found some nits, and we still need tests here.
Nit: Should be "...checks if a given entity exists."
This needs to be final thing in the doc comment, as far as I know, or the annotation will not work.
This should come before the @MigrateProcessPlugin annotation.
nit: Missing a period.
If $this->configuration['entity_type'] is empty, this will fail really hard. Let's check first if that configuration value is set, and throw an InvalidArgumentException if not.
I'd rather return the canonical entity ID, not the input value. Can this be something like:
Missing a newline at the end of the file.
Comment #12
peatonAddressed the feedback in #11
Comment #13
phenaproximaThe patch looks perfect to me now...but it needs tests :)
Comment #14
peatonFixed syntax errors in patch. Added tests.
Comment #15
phenaproximaThis patch looks flawless. Thanks, @peaton!
I would, however, request one small change:
So I know I asked for this to be added originally, but I take that back now. This check is completely pointless -- the configuration value is never used except in create() to get an instance of EntityStorageInterface, which is required by the constructor anyway. If something calls create() with an empty entity_type configuration value, the entity type manager will blow up because the entity type ID will not be valid. So there is no reason at all to throw this exception...let's remove this bit.
Comment #16
peatonOk, removed!
Comment #17
phenaproximaThis looks great. Preemptively RTBC.
Comment #18
catchLooks great. Committed/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!