You are here

FeedImportConfigurable.php in Feed Import 8

File

feed_import_base/src/FeedImportConfigurable.php
View source
<?php

namespace Drupal\feed_import_base;


/**
 * This class provides methods to set options.
 */
abstract class FeedImportConfigurable {

  // Class options
  protected $options = array();

  /**
   * Sets options for this instance
   *
   * @param array $options
   *    An assoc array containig options
   * @param bool $overwrite
   *    TRUE if the options should pe overwritten, FALSE to merge them
   */
  public function setOptions(array $options, $overwrite = FALSE) {
    if ($overwrite) {
      $this->options = $options;
    }
    else {
      $this->options = $options + $this->options;
    }
  }

  /**
   * Helper function to get lines of a string
   *
   * @param string $str
   *    The string to get non empty lines from
   *
   * @return array
   *    An array of strings
   */
  public static function cleanLines($str) {
    return preg_split('/\\r?\\n/', $str);
  }

}

Classes

Namesort descending Description
FeedImportConfigurable This class provides methods to set options.