You are here

function migrate_field_handler_invoke_all in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 migrate.module \migrate_field_handler_invoke_all()

Invoke any available handlers attached to a given field type. If any handlers have dependencies defined, they will be invoked after the specified handlers.

Parameters

$entity: The object we are building up before calling example_save().

$instance: Array of info in the field instance, from field_info_instances().

$values: Array of incoming values, to be transformed into the appropriate structure for the field type.

$method: Handler method to call (defaults to prepare()).

2 calls to migrate_field_handler_invoke_all()
MigrateFieldsNodeHandler::complete in plugins/destinations/fields.inc
MigrateFieldsNodeHandler::prepare in plugins/destinations/fields.inc

File

./migrate.module, line 234

Code

function migrate_field_handler_invoke_all($entity, array $instance, array $values, $method = 'prepare') {
  $return = array();
  $type = $instance['type'];
  $class_list = _migrate_class_list('MigrateFieldHandler');
  $disabled = unserialize(variable_get('migrate_disabled_handlers', serialize(array())));
  foreach ($class_list as $class_name => $handler) {
    if (!in_array($class_name, $disabled) && $handler
      ->handlesType($type) && method_exists($handler, $method)) {
      migrate_instrument_start($class_name . '->' . $method);
      $result = call_user_func_array(array(
        $handler,
        $method,
      ), array(
        $entity,
        $instance,
        $values,
      ));
      migrate_instrument_stop($class_name . '->' . $method);
      if (isset($result) && is_array($result)) {
        $return = array_merge($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }
  return $return;
}