Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\migrate\Plugin;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Component\Plugin\PluginInspectionInterface;
|
Chris@0
|
6 use Drupal\migrate\Row;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Defines an interface for migrate sources.
|
Chris@0
|
10 *
|
Chris@0
|
11 * @see \Drupal\migrate\Plugin\MigratePluginManager
|
Chris@0
|
12 * @see \Drupal\migrate\Annotation\MigrateSource
|
Chris@0
|
13 * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
|
Chris@0
|
14 * @see plugin_api
|
Chris@0
|
15 *
|
Chris@0
|
16 * @ingroup migration
|
Chris@0
|
17 */
|
Chris@0
|
18 interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspectionInterface {
|
Chris@0
|
19
|
Chris@0
|
20 /**
|
Chris@0
|
21 * Returns available fields on the source.
|
Chris@0
|
22 *
|
Chris@0
|
23 * @return array
|
Chris@0
|
24 * Available fields in the source, keys are the field machine names as used
|
Chris@0
|
25 * in field mappings, values are descriptions.
|
Chris@0
|
26 */
|
Chris@0
|
27 public function fields();
|
Chris@0
|
28
|
Chris@0
|
29 /**
|
Chris@0
|
30 * Adds additional data to the row.
|
Chris@0
|
31 *
|
Chris@18
|
32 * @param \Drupal\migrate\Row $row
|
Chris@0
|
33 * The row object.
|
Chris@0
|
34 *
|
Chris@0
|
35 * @return bool
|
Chris@0
|
36 * FALSE if this row needs to be skipped.
|
Chris@0
|
37 */
|
Chris@0
|
38 public function prepareRow(Row $row);
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Allows class to decide how it will react when it is treated like a string.
|
Chris@0
|
42 */
|
Chris@0
|
43 public function __toString();
|
Chris@0
|
44
|
Chris@0
|
45 /**
|
Chris@0
|
46 * Defines the source fields uniquely identifying a source row.
|
Chris@0
|
47 *
|
Chris@0
|
48 * None of these fields should contain a NULL value. If necessary, use
|
Chris@0
|
49 * prepareRow() or hook_migrate_prepare_row() to rewrite NULL values to
|
Chris@0
|
50 * appropriate empty values (such as '' or 0).
|
Chris@0
|
51 *
|
Chris@0
|
52 * @return array[]
|
Chris@0
|
53 * An associative array of field definitions keyed by field ID. Values are
|
Chris@0
|
54 * associative arrays with a structure that contains the field type ('type'
|
Chris@0
|
55 * key). The other keys are the field storage settings as they are returned
|
Chris@12
|
56 * by FieldStorageDefinitionInterface::getSettings().
|
Chris@12
|
57 *
|
Chris@12
|
58 * Examples:
|
Chris@12
|
59 *
|
Chris@12
|
60 * A composite source primary key that is defined by an integer and a string
|
Chris@12
|
61 * might look like this:
|
Chris@0
|
62 * @code
|
Chris@0
|
63 * return [
|
Chris@0
|
64 * 'id' => [
|
Chris@0
|
65 * 'type' => 'integer',
|
Chris@0
|
66 * 'unsigned' => FALSE,
|
Chris@0
|
67 * 'size' => 'big',
|
Chris@0
|
68 * ],
|
Chris@0
|
69 * 'version' => [
|
Chris@0
|
70 * 'type' => 'string',
|
Chris@0
|
71 * 'max_length' => 64,
|
Chris@0
|
72 * 'is_ascii' => TRUE,
|
Chris@0
|
73 * ],
|
Chris@0
|
74 * ];
|
Chris@0
|
75 * @endcode
|
Chris@12
|
76 *
|
Chris@0
|
77 * If 'type' points to a field plugin with multiple columns and needs to
|
Chris@0
|
78 * refer to a column different than 'value', the key of that column will be
|
Chris@0
|
79 * appended as a suffix to the plugin name, separated by dot ('.'). Example:
|
Chris@0
|
80 * @code
|
Chris@0
|
81 * return [
|
Chris@0
|
82 * 'format' => [
|
Chris@0
|
83 * 'type' => 'text.format',
|
Chris@0
|
84 * ],
|
Chris@0
|
85 * ];
|
Chris@0
|
86 * @endcode
|
Chris@12
|
87 *
|
Chris@12
|
88 * Additional custom keys/values that are not part of field storage
|
Chris@12
|
89 * definition can be added as shown below. The most common setting
|
Chris@17
|
90 * passed along to the ID definition is table 'alias', used by the SqlBase
|
Chris@17
|
91 * source plugin in order to distinguish between ambiguous column names -
|
Chris@17
|
92 * for example, when a SQL source query joins two tables with the same
|
Chris@17
|
93 * column names.
|
Chris@0
|
94 * @code
|
Chris@0
|
95 * return [
|
Chris@0
|
96 * 'nid' => [
|
Chris@0
|
97 * 'type' => 'integer',
|
Chris@0
|
98 * 'alias' => 'n',
|
Chris@0
|
99 * ],
|
Chris@0
|
100 * ];
|
Chris@0
|
101 * @endcode
|
Chris@0
|
102 *
|
Chris@0
|
103 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
|
Chris@0
|
104 * @see \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
|
Chris@0
|
105 * @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
|
Chris@0
|
106 * @see \Drupal\text\Plugin\Field\FieldType\TextItem
|
Chris@0
|
107 * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
|
Chris@0
|
108 */
|
Chris@0
|
109 public function getIds();
|
Chris@0
|
110
|
Chris@0
|
111 /**
|
Chris@0
|
112 * Gets the source module providing the source data.
|
Chris@0
|
113 *
|
Chris@0
|
114 * @return string|null
|
Chris@0
|
115 * The source module or NULL if not found.
|
Chris@0
|
116 */
|
Chris@0
|
117 public function getSourceModule();
|
Chris@0
|
118
|
Chris@0
|
119 }
|