From 40013b654ecce7d37fd2078736f7c411e57c53bf Mon Sep 17 00:00:00 2001 From: "v.kydyba" <v.kydyba@3667266.no-reply.drupal.org> Date: Sat, 29 Jan 2022 13:02:41 +0000 Subject: [PATCH] Issue #3256823 by v.kydyba: Simplify code for the gate process plugin --- src/Plugin/migrate/process/Gate.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Plugin/migrate/process/Gate.php b/src/Plugin/migrate/process/Gate.php index 9cdf7957..3cb8f7af 100644 --- a/src/Plugin/migrate/process/Gate.php +++ b/src/Plugin/migrate/process/Gate.php @@ -85,20 +85,20 @@ class Gate extends ProcessPluginBase { * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - if (empty($this->configuration['valid_keys']) && !array_key_exists('valid_keys', $this->configuration)) { + if (!array_key_exists('valid_keys', $this->configuration)) { throw new MigrateException('Gate plugin is missing valid_keys configuration.'); } - if (empty($this->configuration['use_as_key']) && !array_key_exists('use_as_key', $this->configuration)) { + if (!array_key_exists('use_as_key', $this->configuration)) { throw new MigrateException('Gate plugin is missing use_as_key configuration.'); } - if (empty($this->configuration['key_direction']) && !array_key_exists('key_direction', $this->configuration)) { + if (!array_key_exists('key_direction', $this->configuration)) { throw new MigrateException('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.'); } - $valid_keys = is_array($this->configuration['valid_keys']) ? $this->configuration['valid_keys'] : [$this->configuration['valid_keys']]; + $valid_keys = (array) $this->configuration['valid_keys']; $key = $row->get($this->configuration['use_as_key']); $key_is_valid = in_array($key, $valid_keys, TRUE); $key_direction = $this->configuration['key_direction']; -- GitLab