Implementing your own source class - say you're migrating from a database system not supported by Migrate, or from some unusual file format - is not that difficult. You simply need to derive a class from MigrateSource, and implement a few simple methods (well, how simple they are depends on your source...).
Here's a very simple source class that generates ten sample source rows. For more sophisticated examples, review the source classes implemented by Migrate itself in plugins/sources.
<?php
class SimpleMigrateSource extends MigrateSource {
protected $currentId;
protected $numRows;
// Your constructor will initialize any parameters to your migration. It's
// important to pass through the options, so general options such as
// cache_counts will work.
public function __construct($num_rows = 10, array $options = array()) {
parent::__construct($options);
$this->numRows = $num_rows;
}
/**
* Return a string representing the source, for display in the UI.
*/
public function __toString() {
return t('Generate %num sample rows', array('%num' => $this->numRows));
}
/**
* Returns a list of fields available to be mapped from the source,
* keyed by field name.
*/
public function fields() {
return array(
'id' => t('ID'),
'title' => t('Title'),
'body' => t('Body'),
);
}
/**