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(). As an example, for a
57 * composite source primary key that is defined by an integer and a
58 * string, the returned value might look like:
62 * 'type' => 'integer',
63 * 'unsigned' => FALSE,
73 * If 'type' points to a field plugin with multiple columns and needs to
74 * refer to a column different than 'value', the key of that column will be
75 * appended as a suffix to the plugin name, separated by dot ('.'). Example:
79 * 'type' => 'text.format',
83 * Additional custom keys/values, that are not part of field storage
84 * definition, can be passed in definitions. The most common setting, passed
85 * along the ID definition, is 'alias' used by SqlBase source plugin:
89 * 'type' => 'integer',
95 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
96 * @see \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
97 * @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
98 * @see \Drupal\text\Plugin\Field\FieldType\TextItem
99 * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
101 public function getIds();