MigrateSourceMultiItems

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

In some cases the items being imported may be conglomerated (as in an XML feed, where a single retrieval contains many items). In these cases, MigrateSourceMultiItems may be the right choice to represent the source data.

The subordinate MigrateItems class operates much like a fusion of MigrateList and MigrateItem. To define a MigrateItems class for a particular type of source, you need to implement the following methods:

__toString()

Should return a string representing the source of the ID (e.g., the URL of an XML feed).

getIdList()

Should return an array of the IDs available from the source.

computeCount()

Should return a count of the IDs available from the source.

getItem($id)

Given an ID obtained getIdList(), returns the data for the source item keyed by that ID, as an object.

MigrateSourceMultiItems

The MigrateSourceMultiItems class wraps around your MigrateItems object. In your migration constructor, construct a MigrateItems instance, and pass it the MigrateSourceList constructor (you may optionally also pass a source field list and an options array). The MigrateSourceMultiItems instance you create will then iterate over the IDs returned by getIdList(), passing each one to getItem() to obtain source data to be migrated.

See XML-based sources for an example of using these classes in your migration.

Help improve this page

Page status: Not set

You can: