3 namespace Drupal\migrate\Plugin;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\migrate\Row;
9 * Defines an interface for migrate sources.
11 * @see \Drupal\migrate\Plugin\MigratePluginManager
12 * @see \Drupal\migrate\Annotation\MigrateSource
13 * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
18 interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspectionInterface {
21 * Returns available fields on the source.
24 * Available fields in the source, keys are the field machine names as used
25 * in field mappings, values are descriptions.
27 public function fields();
30 * Adds additional data to the row.
32 * @param \Drupal\Migrate\Row $row
36 * FALSE if this row needs to be skipped.
38 public function prepareRow(Row $row);
41 * Allows class to decide how it will react when it is treated like a string.
43 public function __toString();
46 * Defines the source fields uniquely identifying a source row.
48 * None of these fields should contain a NULL value. If necessary, use
49 * prepareRow() or hook_migrate_prepare_row() to rewrite NULL values to
50 * appropriate empty values (such as '' or 0).
53 * An associative array of field definitions keyed by field ID. Values are
54 * associative arrays with a structure that contains the field type ('type'
55 * key). The other keys are the field storage settings as they are returned
56 * by FieldStorageDefinitionInterface::getSettings().
60 * A composite source primary key that is defined by an integer and a string
61 * might look like this:
65 * 'type' => 'integer',
66 * 'unsigned' => FALSE,
77 * If 'type' points to a field plugin with multiple columns and needs to
78 * refer to a column different than 'value', the key of that column will be
79 * appended as a suffix to the plugin name, separated by dot ('.'). Example:
83 * 'type' => 'text.format',
88 * Additional custom keys/values that are not part of field storage
89 * definition can be added as shown below. The most common setting
90 * passed along to the ID definition is table 'alias', used by the SqlBase
91 * source plugin in order to distinguish between ambiguous column names -
92 * for example, when a SQL source query joins two tables with the same
97 * 'type' => 'integer',
103 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
104 * @see \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
105 * @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
106 * @see \Drupal\text\Plugin\Field\FieldType\TextItem
107 * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
109 public function getIds();
112 * Gets the source module providing the source data.
114 * @return string|null
115 * The source module or NULL if not found.
117 public function getSourceModule();