Commit 40013b65 authored by Vasyl Kydyba's avatar Vasyl Kydyba Committed by Ivan Doroshenko
Browse files

Issue #3256823 by v.kydyba: Simplify code for the gate process plugin

parent 66c10109
Loading
Loading
Loading
Loading
+4 −4
Changes for src/Plugin/migrate/process/Gate.php: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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'];