working on an ‘enterprise’ d8 build where pretty much everything is implemented as a custom entity. I’ve been trying to work out how to import data to our entities using Migrate, but all the official documentation I can find relates to “built in” entity types like Nodes, Users and Taxonomies. I’ve been scouring the internet for third party help and still can’t seem to find any good tutorial, reference or example which goes into a custom entity.
Most blog posts / tutorials I’ve found either ignore it completely or handwave it away with a sentence like “Unless you’re using a custom entity in Drupal 8, and migrating data into that entity, you’ll probably never write a Destination Plugin”
OK, but I am so I do need to? I think?
Or do I? Poking around core it looks like this Entity plugin “provides a generic destination to import entities”,and EntityContentBase seems an even closer starting point, and there’s also an EntityRevision plugin (my entities are revisionable). So maybe one of those would work “as is” (my entities are nothing special, just standard field types attached with basefielddefinitions)? Or maybe one of those is the right thing to extend in code, but which? Alternatively, this other page says use the Migration Extras-provided MigrateDestinationEntityAPI “to specify a custom entity as the destination”.
OK, so hopefully one of those three approaches would work, and in the absence of d.o offering useful guidance, unless someone knows here I suppose I’ll just have to try them all and see how I get on. But, meanwhile I also know that many of my entities’ fields are entityreferences to other entities in our system. Googling suggests entity_lookup and entity_generate plugins have got me covered and are even clever enough to stub out as-yet-non-existent referenced entities and fill them in on subsequent migrations. Brilliant! Except this page suggests that the system is currently unable to cope with entities without bundles, and none of my entities have bundles. The issue (and some related I’ve found) are still marked as “needs work” so am I going to get half-way through this process and find myself unable to achieve it without hacking core? With all due respect to myself, if the whole core team havent managed this yet, I’m not sure I fancy myself to solve it!
I’m a tad lost at this point, if anyone can steer me in the right direction I would be very grateful.
submitted by /u/stevekeiretsu
[visit reddit] [comments]