diff --git a/src/Plugin/migrate/process/Gate.php b/src/Plugin/migrate/process/Gate.php index 3cb8f7af3d11ce668c8e27111a2f185b8e050286..3a8bdf3a78226ad823569b707352925ec6ff9664 100644 --- a/src/Plugin/migrate/process/Gate.php +++ b/src/Plugin/migrate/process/Gate.php @@ -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); diff --git a/tests/src/Unit/process/GateTest.php b/tests/src/Unit/process/GateTest.php index 14dd1d3d156695bea7e825bdef1d90ed1e00687a..d1f66f919787382237e5f3aa1a2bd6934aa4794b 100644 --- a/tests/src/Unit/process/GateTest.php +++ b/tests/src/Unit/process/GateTest.php @@ -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', []); } /**