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.
Problem/Motivation
While #1116408: Support migrate module: Destination handler class works great if you are importing redirects that are tied to nodes and entities, I have the need to import redirects from a legacy site that were handed to me in a CSV file. That means we need something like a MigrateDestinationEntity for redirects, in addition to simply a field handler.
i.e.
"URL","Redirect URL"
"/Offer","/product040114001"
Proposed resolution
Create a MigrateDestinationRedirect, similar to MigrateDestinationNode.
Remaining tasks
- Manual testing of MigrateDestinationRedirect
User interface changes
n/a
API changes
Instructions/example should be provided how to use the migrate destination.
Comment | File | Size | Author |
---|---|---|---|
#1 | redirect-migrateDestinationEntity-2238039.patch | 9.83 KB | heddn |
Comments
Comment #1
heddnHere's a patch that provides the necessary functionality. Due to the large number of imported redirects I found some interesting situations. There is some additional logic to handle parsing out URL options that wasn't in #1116408: Support migrate module: Destination handler class that should be included over there, see extractUrlOptions(). I looked into creating a base class to handle this for both migration but without PHP 5.4 and traits, that isn't really possible because of class inheritance. The other solution extends MigrateDestinationHandler while this approach must extend MigrateDestinationEntity.
Comment #2
heddnComment #3
heddnComment #4
benjifisherThis is a duplicate of #1607038: Support migrate module: Individual destination class. It would be great to compare the patch here with the latest one there, and propose an improved patch on the existing issue.