Loading src/Plugin/migrate/process/Gate.php +16 −9 Changes for src/Plugin/migrate/process/Gate.php: 16 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -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', $configuration)) { throw new \InvalidArgumentException('Gate plugin is missing use_as_key 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('key_direction', $configuration)) { throw new \InvalidArgumentException('Gate plugin is missing key_direction configuration.'); } if (!array_key_exists('key_direction', $this->configuration)) { throw new MigrateException('Gate plugin is missing key_direction configuration.'); 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.'); } 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.'); 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); Loading tests/src/Unit/process/GateTest.php +2 −3 Changes for tests/src/Unit/process/GateTest.php: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -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', []); } /** Loading Loading
src/Plugin/migrate/process/Gate.php +16 −9 Changes for src/Plugin/migrate/process/Gate.php: 16 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -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', $configuration)) { throw new \InvalidArgumentException('Gate plugin is missing use_as_key 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('key_direction', $configuration)) { throw new \InvalidArgumentException('Gate plugin is missing key_direction configuration.'); } if (!array_key_exists('key_direction', $this->configuration)) { throw new MigrateException('Gate plugin is missing key_direction configuration.'); 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.'); } 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.'); 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); Loading
tests/src/Unit/process/GateTest.php +2 −3 Changes for tests/src/Unit/process/GateTest.php: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -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', []); } /** Loading