You are here

public function FeedImportMultiFilter::add in Feed Import 8

Adds a new filter.

Parameters

string $group: The name of filter group

string $name: Filters name

string $function: The function name. Use Class::method for static methods.

array $params: The params for this function.

Return value

boolean TRUE if filter was added.

File

feed_import_base/src/FeedImportMultiFilter.php, line 100

Class

FeedImportMultiFilter
This class is used to apply several filters to a value in a quick way.

Namespace

Drupal\feed_import_base

Code

public function add($group, $name, $function, $params = array()) {

  // Get function name.
  if (!($function = $this
    ->getCallable($function))) {
    return FALSE;
  }

  // Create function info.
  $f = array(
    // Function name
    'f' => $function,
    // Params.
    'p' => array_values($params),
    // A reference to dynamic param.
    'd' => NULL,
  );

  // Check params for dynamic fields.
  for ($i = 0, $m = count($f['p']); $i < $m; $i++) {
    if ($f['p'][$i] === $this->dynParam) {

      // Set reference to dynamic param.
      $f['p'][$i] =& $f['d'];
    }
  }

  // Add to filters array.
  $this->filters[$group][$name][] =& $f;

  // All good, filter was added.
  return TRUE;
}