a2a7fb2d94d4078a7df5aedf84a63a19093d1aab
[yaffs-website] / web / core / modules / migrate / src / Plugin / MigrationInterface.php
1 <?php
2
3 namespace Drupal\migrate\Plugin;
4
5 use Drupal\Component\Plugin\DerivativeInspectionInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7
8 /**
9  * Interface for migrations.
10  */
11 interface MigrationInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
12
13   /**
14    * The migration is currently not running.
15    */
16   const STATUS_IDLE = 0;
17
18   /**
19    * The migration is currently importing.
20    */
21   const STATUS_IMPORTING = 1;
22
23   /**
24    * The migration is currently being rolled back.
25    */
26   const STATUS_ROLLING_BACK = 2;
27
28   /**
29    * The migration is being stopped.
30    */
31   const STATUS_STOPPING = 3;
32
33   /**
34    * The migration has been disabled.
35    */
36   const STATUS_DISABLED = 4;
37
38   /**
39    * Migration error.
40    */
41   const MESSAGE_ERROR = 1;
42
43   /**
44    * Migration warning.
45    */
46   const MESSAGE_WARNING = 2;
47
48   /**
49    * Migration notice.
50    */
51   const MESSAGE_NOTICE = 3;
52
53   /**
54    * Migration info.
55    */
56   const MESSAGE_INFORMATIONAL = 4;
57
58   /**
59    * All records have been processed.
60    */
61   const RESULT_COMPLETED = 1;
62
63   /**
64    * The process has stopped itself (e.g., the memory limit is approaching).
65    */
66   const RESULT_INCOMPLETE = 2;
67
68   /**
69    * The process was stopped externally (e.g., via drush migrate-stop).
70    */
71   const RESULT_STOPPED = 3;
72
73   /**
74    * The process had a fatal error.
75    */
76   const RESULT_FAILED = 4;
77
78   /**
79    * Dependencies are unfulfilled - skip the process.
80    */
81   const RESULT_SKIPPED = 5;
82
83   /**
84    * This migration is disabled, skipping.
85    */
86   const RESULT_DISABLED = 6;
87
88   /**
89    * An alias for getPluginId() for backwards compatibility reasons.
90    *
91    * @return string
92    *   The plugin_id of the plugin instance.
93    *
94    * @see \Drupal\migrate\Plugin\MigrationInterface::getPluginId()
95    */
96   public function id();
97
98   /**
99    * Get the plugin label.
100    *
101    * @return string
102    *   The label for this migration.
103    */
104   public function label();
105
106   /**
107    * Returns the initialized source plugin.
108    *
109    * @return \Drupal\migrate\Plugin\MigrateSourceInterface
110    *   The source plugin.
111    */
112   public function getSourcePlugin();
113
114   /**
115    * Returns the process plugins.
116    *
117    * @param array $process
118    *   A process configuration array.
119    *
120    * @return \Drupal\migrate\Plugin\MigrateProcessInterface[][]
121    *   An associative array. The keys are the destination property names. Values
122    *   are process pipelines. Each pipeline contains an array of plugins.
123    */
124   public function getProcessPlugins(array $process = NULL);
125
126   /**
127    * Returns the initialized destination plugin.
128    *
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    * Returns the initialized id_map plugin.
139    *
140    * @return \Drupal\migrate\Plugin\MigrateIdMapInterface
141    *   The ID map.
142    */
143   public function getIdMap();
144
145   /**
146    * Check if all source rows from this migration have been processed.
147    *
148    * @return bool
149    *   TRUE if this migration is complete otherwise FALSE.
150    */
151   public function allRowsProcessed();
152
153   /**
154    * Set the current migration status.
155    *
156    * @param int $status
157    *   One of the STATUS_* constants.
158    */
159   public function setStatus($status);
160
161   /**
162    * Get the current migration status.
163    *
164    * @return int
165    *   The current migration status. Defaults to STATUS_IDLE.
166    */
167   public function getStatus();
168
169   /**
170    * Retrieve a label for the current status.
171    *
172    * @return string
173    *   User-friendly string corresponding to a STATUS_ constant.
174    */
175   public function getStatusLabel();
176
177   /**
178    * Get the result to return upon interruption.
179    *
180    * @return int
181    *   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    * Signal that the migration should be interrupted with the specified result
192    * code.
193    *
194    * @param int $result
195    *   One of the MigrationInterface::RESULT_* constants.
196    */
197   public function interruptMigration($result);
198
199   /**
200    * Get the normalized process pipeline configuration describing the process
201    * plugins.
202    *
203    * The process configuration is always normalized. All shorthand processing
204    * will be expanded into their full representations.
205    *
206    * @see https://www.drupal.org/node/2129651#get-shorthand
207    *
208    * @return array
209    *   The normalized configuration describing the process plugins.
210    */
211   public function getProcess();
212
213   /**
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    * @return $this
220    */
221   public function setProcess(array $process);
222
223   /**
224    * Set the process pipeline configuration for an individual destination field.
225    *
226    * This method allows you to set the process pipeline configuration for a
227    * single property within the full process pipeline configuration.
228    *
229    * @param string $property
230    *   The property of which to set the process pipeline configuration.
231    * @param mixed $process_of_property
232    *   The process pipeline configuration to be set for this property.
233    *
234    * @return $this
235    *   The migration entity.
236    */
237   public function setProcessOfProperty($property, $process_of_property);
238
239   /**
240    * Merge the process pipeline configuration for a single property.
241    *
242    * @param string $property
243    *   The property of which to merge the passed in process pipeline
244    *   configuration.
245    * @param array $process_of_property
246    *   The process pipeline configuration to be merged with the existing process
247    *   pipeline configuration.
248    *
249    * @return $this
250    *   The migration entity.
251    *
252    * @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField()
253    */
254   public function mergeProcessOfProperty($property, array $process_of_property);
255
256   /**
257    * Checks if the migration should track time of last import.
258    *
259    * @return bool
260    *   TRUE if the migration is tracking last import time.
261    */
262   public function isTrackLastImported();
263
264   /**
265    * Set if the migration should track time of last import.
266    *
267    * @param bool $track_last_imported
268    *   Boolean value to indicate if the migration should track last import time.
269    *
270    * @return $this
271    */
272   public function setTrackLastImported($track_last_imported);
273
274   /**
275    * Get the dependencies for this migration.
276    *
277    * @return array
278    *   The dependencies for this migrations.
279    */
280   public function getMigrationDependencies();
281
282   /**
283    * Get the destination configuration, with at least a 'plugin' key.
284    *
285    * @return array
286    *   The destination configuration.
287    */
288   public function getDestinationConfiguration();
289
290   /**
291    * Get the source configuration, with at least a 'plugin' key.
292    *
293    * @return array
294    *   The source configuration.
295    */
296   public function getSourceConfiguration();
297
298   /**
299    * If true, track time of last import.
300    *
301    * @return bool
302    *   Flag to determine desire of tracking time of last import.
303    */
304   public function getTrackLastImported();
305
306   /**
307    * The destination identifiers.
308    *
309    * An array of destination identifiers: the keys are the name of the
310    * properties, the values are dependent on the ID map plugin.
311    *
312    * @return array
313    *   Destination identifiers.
314    */
315   public function getDestinationIds();
316
317   /**
318    * The migration tags.
319    *
320    * @return array
321    *   Migration tags.
322    */
323   public function getMigrationTags();
324
325 }