In some cases, the data to import may come in two pieces:
- a list of items to be imported
- the data for each distinct item (selected by an identifer from the list).
This migration pattern is supported by the
MigrateSourceList source class, along with its helper classes
MigrateList (representing the id list) and MigrateItem (representing individual source elements).
MigrateList is an abstract base class representing a list of unique keys identifying items to be migrated. To define a MigrateList extension for a particular source (such as an XML feed of identifiers), you need to define the following methods below. See the Migrate module's MigrateListXML and MigrateListJSON for concrete examples of implementing a list class.
The following methods should be implemented by MigrateList sources:
__toString(): Should return a string representing the source of the list (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.
MigrateItem is an abstract base class representing a single item to be migrated, keyed by an ID obtained from a MigrateList class. There is one essential method to be implemented - see the Migrate module's MigrateItemXML and MigrateItemJSONfor concrete examples of implementing an item class.
Methods to be implemented are:
getItem($id): Given an ID obtained from a MigrateList class, returns the data for the source item keyed by that ID, as an object.
MigrateSourceList class ties together your
MigrateItem classes. In your migration constructor, construct a MigrateList and MigrateItem instance, and pass them to the MigrateSourceList constructor (you may optionally also pass a source field list and an options array). The MigrateSourceList instance you create will then iterate over the IDs provided by the MigrateList instance, passing each one to the MigrateItem instance to obtain source data to be migrated.