3 namespace Drupal\migrate\Plugin\migrate\process;
5 use Drupal\migrate\MigrateSkipProcessException;
6 use Drupal\migrate\ProcessPluginBase;
7 use Drupal\migrate\MigrateExecutableInterface;
8 use Drupal\migrate\Row;
9 use Drupal\migrate\MigrateSkipRowException;
12 * Skips processing the current row when the input value is empty.
14 * The skip_on_empty process plugin checks to see if the current input value
15 * is empty (empty string, NULL, FALSE, 0, '0', or an empty array). If so, the
16 * further processing of the property or the entire row (depending on the chosen
17 * method) is skipped and will not be migrated.
19 * Available configuration keys:
20 * - method: (optional) What to do if the input value is empty. Possible values:
21 * - row: Skips the entire row when an empty value is encountered.
22 * - process: Prevents further processing of the input property when the value
24 * - message: (optional) A message to be logged in the {migrate_message_*} table
25 * for this row. Messages are only logged for the 'row' method. If not set,
26 * nothing is logged in the message table.
33 * plugin: skip_on_empty
36 * message: 'Field field_name is missing'
38 * If 'field_name' is empty, the entire row is skipped and the message 'Field
39 * field_name is missing' is logged in the message table.
45 * plugin: skip_on_empty
49 * plugin: migration_lookup
50 * migration: d6_taxonomy_term
52 * If 'parent' is empty, any further processing of the property is skipped and
53 * the next process plugin (migration_lookup) will not be run. Combining
54 * skip_on_empty and migration_lookup is a typical process pipeline combination
55 * for hierarchical entities where the root entity does not have a parent.
57 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
59 * @MigrateProcessPlugin(
60 * id = "skip_on_empty"
63 class SkipOnEmpty extends ProcessPluginBase {
66 * Skips the current row when value is not set.
70 * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
71 * The migration in which this process is being executed.
72 * @param \Drupal\migrate\Row $row
73 * The row from the source to process.
74 * @param string $destination_property
75 * The destination property currently worked on. This is only used together
76 * with the $row above.
79 * The input value, $value, if it is not empty.
81 * @throws \Drupal\migrate\MigrateSkipRowException
82 * Thrown if the source property is not set and the row should be skipped,
83 * records with STATUS_IGNORED status in the map.
85 public function row($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
87 $message = !empty($this->configuration['message']) ? $this->configuration['message'] : '';
88 throw new MigrateSkipRowException($message);
94 * Stops processing the current property when value is not set.
98 * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
99 * The migration in which this process is being executed.
100 * @param \Drupal\migrate\Row $row
101 * The row from the source to process.
102 * @param string $destination_property
103 * The destination property currently worked on. This is only used together
104 * with the $row above.
107 * The input value, $value, if it is not empty.
109 * @throws \Drupal\migrate\MigrateSkipProcessException
110 * Thrown if the source property is not set and rest of the process should
113 public function process($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
115 throw new MigrateSkipProcessException();