MigrationInterface.php 7.59 KB
Newer Older
1 2
<?php

3
namespace Drupal\migrate\Plugin;
4

5 6
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
7

8 9 10
/**
 * Interface for migrations.
 */
11
interface MigrationInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
12 13

  /**
14
   * The migration is currently not running.
15 16
   */
  const STATUS_IDLE = 0;
17 18 19 20

  /**
   * The migration is currently importing.
   */
21
  const STATUS_IMPORTING = 1;
22 23 24 25

  /**
   * The migration is currently being rolled back.
   */
26
  const STATUS_ROLLING_BACK = 2;
27 28 29 30

  /**
   * The migration is being stopped.
   */
31
  const STATUS_STOPPING = 3;
32 33 34 35

  /**
   * The migration has been disabled.
   */
36 37 38
  const STATUS_DISABLED = 4;

  /**
39
   * Migration error.
40 41
   */
  const MESSAGE_ERROR = 1;
42 43 44 45

  /**
   * Migration warning.
   */
46
  const MESSAGE_WARNING = 2;
47 48 49 50

  /**
   * Migration notice.
   */
51
  const MESSAGE_NOTICE = 3;
52 53 54 55

  /**
   * Migration info.
   */
56 57 58
  const MESSAGE_INFORMATIONAL = 4;

  /**
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
   * All records have been processed.
   */
  const RESULT_COMPLETED = 1;

  /**
   * The process has stopped itself (e.g., the memory limit is approaching).
   */
  const RESULT_INCOMPLETE = 2;

  /**
   * The process was stopped externally (e.g., via drush migrate-stop).
   */
  const RESULT_STOPPED = 3;

  /**
   * The process had a fatal error.
   */
  const RESULT_FAILED = 4;

  /**
   * Dependencies are unfulfilled - skip the process.
   */
  const RESULT_SKIPPED = 5;

  /**
   * This migration is disabled, skipping.
85
   */
86
  const RESULT_DISABLED = 6;
87

88 89 90 91 92 93
  /**
   * An alias for getPluginId() for backwards compatibility reasons.
   *
   * @return string
   *   The plugin_id of the plugin instance.
   *
94
   * @see \Drupal\migrate\Plugin\MigrationInterface::getPluginId()
95 96 97 98 99 100 101 102 103 104 105
   */
  public function id();

  /**
   * Get the plugin label.
   *
   * @return string
   *   The label for this migration.
   */
  public function label();

106 107 108 109
  /**
   * Returns the initialized source plugin.
   *
   * @return \Drupal\migrate\Plugin\MigrateSourceInterface
110
   *   The source plugin.
111 112 113 114 115 116 117 118 119
   */
  public function getSourcePlugin();

  /**
   * Returns the process plugins.
   *
   * @param array $process
   *   A process configuration array.
   *
120 121 122
   * @return \Drupal\migrate\Plugin\MigrateProcessInterface[][]
   *   An associative array. The keys are the destination property names. Values
   *   are process pipelines. Each pipeline contains an array of plugins.
123 124 125 126 127 128
   */
  public function getProcessPlugins(array $process = NULL);

  /**
   * Returns the initialized destination plugin.
   *
129
   * @param bool $stub_being_requested
130
   *   TRUE to indicate that this destination will be asked to construct a stub.
131
   *
132
   * @return \Drupal\migrate\Plugin\MigrateDestinationInterface
133
   *   The destination plugin.
134
   */
135
  public function getDestinationPlugin($stub_being_requested = FALSE);
136 137 138 139 140

  /**
   * Returns the initialized id_map plugin.
   *
   * @return \Drupal\migrate\Plugin\MigrateIdMapInterface
141
   *   The ID map.
142 143 144
   */
  public function getIdMap();

145
  /**
146
   * Check if all source rows from this migration have been processed.
147 148 149 150
   *
   * @return bool
   *   TRUE if this migration is complete otherwise FALSE.
   */
151
  public function allRowsProcessed();
152

153 154 155
  /**
   * Set the current migration status.
   *
156
   * @param int $status
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
   *   One of the STATUS_* constants.
   */
  public function setStatus($status);

  /**
   * Get the current migration status.
   *
   * @return int
   *   The current migration status. Defaults to STATUS_IDLE.
   */
  public function getStatus();

  /**
   * Retrieve a label for the current status.
   *
   * @return string
   *   User-friendly string corresponding to a STATUS_ constant.
   */
  public function getStatusLabel();

177
  /**
178
   * Get the result to return upon interruption.
179
   *
180 181
   * @return int
   *   The current interruption result. Defaults to RESULT_INCOMPLETE.
182
   */
183
  public function getInterruptionResult();
184 185

  /**
186
   * Clears the result to return upon interruption.
187
   */
188
  public function clearInterruptionResult();
189

190 191 192 193 194 195 196 197 198
  /**
   * Signal that the migration should be interrupted with the specified result
   * code.
   *
   * @param int $result
   *   One of the MigrationInterface::RESULT_* constants.
   */
  public function interruptMigration($result);

199
  /**
200 201 202 203 204 205 206
   * Get the normalized process pipeline configuration describing the process
   * plugins.
   *
   * The process configuration is always normalized. All shorthand processing
   * will be expanded into their full representations.
   *
   * @see https://www.drupal.org/node/2129651#get-shorthand
207 208
   *
   * @return array
209
   *   The normalized configuration describing the process plugins.
210 211 212 213
   */
  public function getProcess();

  /**
214
   * Allows you to override the entire process configuration.
215 216
   *
   * @param array $process
217
   *   The entire process pipeline configuration describing the process plugins.
218 219 220 221 222
   *
   * @return $this
   */
  public function setProcess(array $process);

223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
  /**
   * Set the process pipeline configuration for an individual destination field.
   *
   * This method allows you to set the process pipeline configuration for a
   * single property within the full process pipeline configuration.
   *
   * @param string $property
   *   The property of which to set the process pipeline configuration.
   * @param mixed $process_of_property
   *   The process pipeline configuration to be set for this property.
   *
   * @return $this
   *   The migration entity.
   */
  public function setProcessOfProperty($property, $process_of_property);

  /**
   * Merge the process pipeline configuration for a single property.
   *
   * @param string $property
   *   The property of which to merge the passed in process pipeline
244
   *   configuration.
245 246
   * @param array $process_of_property
   *   The process pipeline configuration to be merged with the existing process
247
   *   pipeline configuration.
248 249 250 251
   *
   * @return $this
   *   The migration entity.
   *
252
   * @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField()
253 254 255
   */
  public function mergeProcessOfProperty($property, array $process_of_property);

256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
  /**
   * Checks if the migration should track time of last import.
   *
   * @return bool
   *   TRUE if the migration is tracking last import time.
   */
  public function isTrackLastImported();

  /**
   * Set if the migration should track time of last import.
   *
   * @param bool $track_last_imported
   *   Boolean value to indicate if the migration should track last import time.
   *
   * @return $this
   */
  public function setTrackLastImported($track_last_imported);

  /**
   * Get the dependencies for this migration.
   *
   * @return array
   *   The dependencies for this migrations.
   */
  public function getMigrationDependencies();

282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
  /**
   * Get the destination configuration, with at least a 'plugin' key.
   *
   * @return array
   *   The destination configuration.
   */
  public function getDestinationConfiguration();

  /**
   * Get the source configuration, with at least a 'plugin' key.
   *
   * @return array
   *   The source configuration.
   */
  public function getSourceConfiguration();

  /**
   * If true, track time of last import.
   *
   * @return bool
   *   Flag to determine desire of tracking time of last import.
   */
  public function getTrackLastImported();

  /**
   * The destination identifiers.
   *
   * An array of destination identifiers: the keys are the name of the
   * properties, the values are dependent on the ID map plugin.
   *
   * @return array
   *   Destination identifiers.
   */
  public function getDestinationIds();

317 318 319 320 321 322 323 324
  /**
   * The migration tags.
   *
   * @return array
   *   Migration tags.
   */
  public function getMigrationTags();

325
}