You are here

public function FeedImportProcessor::setOptions in Feed Import 8

Sets options for this instance

Parameters

array $options: An assoc array containig options

bool $overwrite: TRUE if the options should pe overwritten, FALSE to merge them

Overrides FeedImportConfigurable::setOptions

File

feed_import_base/src/FeedImportProcessor.php, line 204

Class

FeedImportProcessor
Class that processess the import.

Namespace

Drupal\feed_import_base

Code

public function setOptions(array $options, $overwrite = FALSE) {
  if (isset($options['items_count']) && $options['items_count'] >= 0) {
    $this->itemsCount = (int) $options['items_count'];
  }
  if (isset($options['skip_imported'])) {
    $this->skipImportedItems = (bool) $options['skip_imported'];
  }
  if (isset($options['max_reported_errors'])) {
    $this->errorsLeft = (int) $options['max_reported_errors'];
  }
  if (isset($options['throw_exception'])) {
    $this->throwException = (bool) $options['throw_exception'];
  }
  if (isset($options['reset_cache']) && $options['reset_cache'] >= 0) {
    $this->resetStaticCache = (int) $options['reset_cache'];
  }
  if (isset($options['skip_defined_functions_check'])) {
    $this->skipDefFunChk = (bool) $options['skip_defined_functions_check'];
  }
  if (isset($options['break_on_undefined_filter'])) {
    $this->breakOnUndefinedFilter = (bool) $options['break_on_undefined_filter'];
  }
  if (isset($options['updates_only'])) {
    $this->updatesOnly = (bool) $options['updates_only'];
  }
  $cbks = array(
    'before_combine' => &$this->beforeCombine,
    'after_combine' => &$this->afterCombine,
    'before_create' => &$this->beforeCreate,
    'before_save' => &$this->beforeSave,
    'after_save' => &$this->afterSave,
    'uniq_callback' => &$this->uniqAlter,
  );
  foreach ($cbks as $opt => &$val) {
    if (!empty($options[$opt])) {
      $val = $options[$opt];
    }
  }
  return TRUE;
}