Skip to content
Snippets Groups Projects
Commit c3ec3aca authored by Ivan Doroshenko's avatar Ivan Doroshenko
Browse files

Merge remote-tracking branch 'origin/8.x-5.x' into 3015199-allow-skiponvalue-to

parents e612db7c ef77138d
No related branches found
No related tags found
1 merge request!33Issue #3015199: Allow SkipOnValue to include a message in the MigrateSkipRowException.
......@@ -84,20 +84,27 @@ class Gate extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!array_key_exists('valid_keys', $this->configuration)) {
throw new MigrateException('Gate plugin is missing valid_keys configuration.');
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
if (!array_key_exists('valid_keys', $configuration)) {
throw new \InvalidArgumentException('Gate plugin is missing valid_keys configuration.');
}
if (!array_key_exists('use_as_key', $this->configuration)) {
throw new MigrateException('Gate plugin is missing use_as_key configuration.');
if (!array_key_exists('use_as_key', $configuration)) {
throw new \InvalidArgumentException('Gate plugin is missing use_as_key configuration.');
}
if (!array_key_exists('key_direction', $this->configuration)) {
throw new MigrateException('Gate plugin is missing key_direction configuration.');
if (!array_key_exists('key_direction', $configuration)) {
throw new \InvalidArgumentException('Gate plugin is missing key_direction configuration.');
}
if (!in_array($this->configuration['key_direction'], ['lock', 'unlock'], TRUE)) {
throw new MigrateException('Gate plugin only accepts the following values for key_direction: lock and unlock.');
if (!in_array($configuration['key_direction'], ['lock', 'unlock'], TRUE)) {
throw new \InvalidArgumentException('Gate plugin only accepts the following values for key_direction: lock and unlock.');
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$valid_keys = (array) $this->configuration['valid_keys'];
$key = $row->get($this->configuration['use_as_key']);
$key_is_valid = in_array($key, $valid_keys, TRUE);
......
......@@ -156,10 +156,9 @@ class GateTest extends MigrateProcessTestCase {
* @dataProvider badConfigurationProvider
*/
public function testGateBadConfigration($configuration, $message): void {
$this->expectException(MigrateException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage($message);
$plugin = new Gate($configuration, 'gate', []);
$plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
new Gate($configuration, 'gate', []);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment