Problem/Motivation

Some of the code in the recently added gate plugin can be simplified.

Proposed resolution

There are three tests like this:

    if (empty($this->configuration['valid_keys']) && !array_key_exists('valid_keys', $this->configuration)) {
      throw new MigrateException('Gate plugin is missing valid_keys configuration.');
    }

Just the second condition is enough:

    if (!array_key_exists('valid_keys', $this->configuration)) {
      throw new MigrateException('Gate plugin is missing valid_keys configuration.');
    }

The line

    $valid_keys = is_array($this->configuration['valid_keys']) ? $this->configuration['valid_keys'] : [$this->configuration['valid_keys']];

can be replaced with

    $valid_keys = (array) $this->configuration['valid_keys'];

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

benjifisher created an issue. See original summary.

matroskeen’s picture

Issue tags: +LutskGCW22

v.kydyba made their first commit to this issue’s fork.

v.kydyba’s picture

Assigned: Unassigned » v.kydyba

matroskeen’s picture

Status: Active » Needs work

2 more conditions to fix :)

v.kydyba’s picture

Status: Needs work » Needs review
matroskeen’s picture

  • Matroskeen committed 40013b6 on 8.x-5.x authored by v.kydyba
    Issue #3256823 by v.kydyba: Simplify code for the gate process plugin
    
matroskeen’s picture

Assigned: v.kydyba » Unassigned
Status: Needs review » Fixed

Looks good to me. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.