You are here

protected function DomApplyStyles::validateRules in Migrate Plus 8.5

Validate the configured rules.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to DomApplyStyles::validateRules()
DomApplyStyles::__construct in src/Plugin/migrate/process/DomApplyStyles.php
Constructs a \Drupal\Component\Plugin\PluginBase object.

File

src/Plugin/migrate/process/DomApplyStyles.php, line 149

Class

DomApplyStyles
Apply Editor styles to configured elements.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function validateRules() {
  if (!array_key_exists('rules', $this->configuration) || !is_array($this->configuration['rules'])) {
    $message = 'The "rules" option must be an array.';
    throw new InvalidPluginDefinitionException($this
      ->getPluginId(), $message);
  }
  foreach ($this->configuration['rules'] as $rule) {
    if (empty($rule['xpath']) || empty($rule['style'])) {
      $message = 'The "xpath" and "style" options are required for each rule.';
      throw new InvalidPluginDefinitionException($this
        ->getPluginId(), $message);
    }
    if (empty($this->styles[$rule['style']])) {
      $message = sprintf('The style "%s" is not defined.', $rule['style']);
      throw new InvalidPluginDefinitionException($this
        ->getPluginId(), $message);
    }
  }
}