Newer
Older
Benji Fisher
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
<?php
namespace Drupal\migrate_devel\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* Debug the process pipeline.
*
* Prints the input value, assuming that you are running the migration from the
* command line, and sends it to the next step in the pipeline unaltered.
*
* Available configuration keys:
* - label: (optional) a string to print before the debug output. Include any
* trailing punctuation or space characters.
* - multiple: (optional) set to TRUE to ask the next step in the process
* pipeline to process array values individually, like the multiple_values
* plugin from the Migrate Plus module.
*
* Examples:
*
* @code
* process:
* field_tricky:
* -
* plugin: debug
* source: whatever
* -
* plugin: next
* @endcode
*
* This will print the source before passing it to the next plugin.
*
* @code
* process:
* field_tricky:
* -
* plugin: debug
* source: whatever
* label: 'Step 1: '
* multiple: true
* -
* plugin: next
* @endcode
*
* This does the same thing, but ensures that the next plugin will be called
* once for each item in the source, if the source is an array.
* It will also print "Debug Step 1: " before printing the source.
*
* @see \Drupal\migrate\Plugin\MigrateProcessInterface
*
* @MigrateProcessPlugin(
* id = "debug",
* handle_multiples = TRUE
* )
*/
class Debug extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (isset($this->configuration['label'])) {
print_r($this->configuration['label']);
}
print_r($value);
if (!is_array($value)) {
print_r(PHP_EOL);
}
return $value;
}
/**
* {@inheritdoc}
*/
public function multiple() {
return !empty($this->configuration['multiple']);
}
}