You are here

protected function FeedImportMultiFilter::getCallable in Feed Import 8

Parse function name and returns a callable.

Parameters

string $function: The function to parse

Return value

mixed A callable string|array or FALSE

1 call to FeedImportMultiFilter::getCallable()
FeedImportMultiFilter::add in feed_import_base/src/FeedImportMultiFilter.php
Adds a new filter.

File

feed_import_base/src/FeedImportMultiFilter.php, line 61

Class

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

Namespace

Drupal\feed_import_base

Code

protected function getCallable($function) {
  if (is_scalar($function)) {
    if (strpos($function, '::') !== FALSE) {
      $function = explode('::', $function, 2);
      if (!$function[0]) {
        $function[0] = static::$defaultFilterClass;
      }
      if (!class_exists($function[0]) || !method_exists($function[0], $function[1])) {

        // Class or method not found.
        return FALSE;
      }
    }
    elseif (!function_exists($function)) {

      // Function not found.
      return FALSE;
    }
  }
  elseif (!class_exists($function[0]) || !method_exists($function[0], $function[1])) {

    // Class or method not found.
    return FALSE;
  }
  return $function;
}