annotate 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
rev   line source
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@0 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@0 56 * by FieldStorageDefinitionInterface::getSettings(). As an example, for a
Chris@0 57 * composite source primary key that is defined by an integer and a
Chris@0 58 * string, the returned value might look like:
Chris@0 59 * @code
Chris@0 60 * return [
Chris@0 61 * 'id' => [
Chris@0 62 * 'type' => 'integer',
Chris@0 63 * 'unsigned' => FALSE,
Chris@0 64 * 'size' => 'big',
Chris@0 65 * ],
Chris@0 66 * 'version' => [
Chris@0 67 * 'type' => 'string',
Chris@0 68 * 'max_length' => 64,
Chris@0 69 * 'is_ascii' => TRUE,
Chris@0 70 * ],
Chris@0 71 * ];
Chris@0 72 * @endcode
Chris@0 73 * If 'type' points to a field plugin with multiple columns and needs to
Chris@0 74 * refer to a column different than 'value', the key of that column will be
Chris@0 75 * appended as a suffix to the plugin name, separated by dot ('.'). Example:
Chris@0 76 * @code
Chris@0 77 * return [
Chris@0 78 * 'format' => [
Chris@0 79 * 'type' => 'text.format',
Chris@0 80 * ],
Chris@0 81 * ];
Chris@0 82 * @endcode
Chris@0 83 * Additional custom keys/values, that are not part of field storage
Chris@0 84 * definition, can be passed in definitions. The most common setting, passed
Chris@0 85 * along the ID definition, is 'alias' used by SqlBase source plugin:
Chris@0 86 * @code
Chris@0 87 * return [
Chris@0 88 * 'nid' => [
Chris@0 89 * 'type' => 'integer',
Chris@0 90 * 'alias' => 'n',
Chris@0 91 * ],
Chris@0 92 * ];
Chris@0 93 * @endcode
Chris@0 94 *
Chris@0 95 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
Chris@0 96 * @see \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
Chris@0 97 * @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
Chris@0 98 * @see \Drupal\text\Plugin\Field\FieldType\TextItem
Chris@0 99 * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
Chris@0 100 */
Chris@0 101 public function getIds();
Chris@0 102
Chris@0 103 /**
Chris@0 104 * Gets the source module providing the source data.
Chris@0 105 *
Chris@0 106 * @return string|null
Chris@0 107 * The source module or NULL if not found.
Chris@0 108 */
Chris@0 109 public function getSourceModule();
Chris@0 110
Chris@0 111 }