Mercurial > hg > isophonics-drupal-site
comparison core/modules/migrate/src/Plugin/MigrateSourceInterface.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\migrate\Plugin; | |
4 | |
5 use Drupal\Component\Plugin\PluginInspectionInterface; | |
6 use Drupal\migrate\Row; | |
7 | |
8 /** | |
9 * Defines an interface for migrate sources. | |
10 * | |
11 * @see \Drupal\migrate\Plugin\MigratePluginManager | |
12 * @see \Drupal\migrate\Annotation\MigrateSource | |
13 * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase | |
14 * @see plugin_api | |
15 * | |
16 * @ingroup migration | |
17 */ | |
18 interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspectionInterface { | |
19 | |
20 /** | |
21 * Returns available fields on the source. | |
22 * | |
23 * @return array | |
24 * Available fields in the source, keys are the field machine names as used | |
25 * in field mappings, values are descriptions. | |
26 */ | |
27 public function fields(); | |
28 | |
29 /** | |
30 * Adds additional data to the row. | |
31 * | |
32 * @param \Drupal\Migrate\Row $row | |
33 * The row object. | |
34 * | |
35 * @return bool | |
36 * FALSE if this row needs to be skipped. | |
37 */ | |
38 public function prepareRow(Row $row); | |
39 | |
40 /** | |
41 * Allows class to decide how it will react when it is treated like a string. | |
42 */ | |
43 public function __toString(); | |
44 | |
45 /** | |
46 * Defines the source fields uniquely identifying a source row. | |
47 * | |
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). | |
51 * | |
52 * @return array[] | |
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: | |
59 * @code | |
60 * return [ | |
61 * 'id' => [ | |
62 * 'type' => 'integer', | |
63 * 'unsigned' => FALSE, | |
64 * 'size' => 'big', | |
65 * ], | |
66 * 'version' => [ | |
67 * 'type' => 'string', | |
68 * 'max_length' => 64, | |
69 * 'is_ascii' => TRUE, | |
70 * ], | |
71 * ]; | |
72 * @endcode | |
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: | |
76 * @code | |
77 * return [ | |
78 * 'format' => [ | |
79 * 'type' => 'text.format', | |
80 * ], | |
81 * ]; | |
82 * @endcode | |
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: | |
86 * @code | |
87 * return [ | |
88 * 'nid' => [ | |
89 * 'type' => 'integer', | |
90 * 'alias' => 'n', | |
91 * ], | |
92 * ]; | |
93 * @endcode | |
94 * | |
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 | |
100 */ | |
101 public function getIds(); | |
102 | |
103 /** | |
104 * Gets the source module providing the source data. | |
105 * | |
106 * @return string|null | |
107 * The source module or NULL if not found. | |
108 */ | |
109 public function getSourceModule(); | |
110 | |
111 } |