You are here

function migrate_ui_handlers_form in Migrate 6.2

Form for reviewing migrations.

1 string reference to 'migrate_ui_handlers_form'
migrate_ui_handlers in migrate_ui/migrate_ui.pages.inc
Menu callback

File

migrate_ui/migrate_ui.pages.inc, line 815

Code

function migrate_ui_handlers_form() {
  $build = array();
  $build['handlers'] = array(
    '#type' => 'fieldset',
    '#title' => t('Handler configuration'),
    '#description' => t('In some cases, such as when a field handler for a contributed module is
          implemented in both migrate_extras and the module itself, you may need to disable
          a particular handler. In this case, you may uncheck the undesired handler below.'),
  );
  $build['handlers']['destination'] = array(
    '#type' => 'fieldset',
    '#title' => t('Destination handlers'),
    '#collapsible' => TRUE,
  );
  $header = array(
    'module' => array(
      'data' => t('Module'),
    ),
    'class' => array(
      'data' => t('Class'),
    ),
    'types' => array(
      'data' => t('Destination types handled'),
    ),
  );
  $disabled = unserialize(variable_get('migrate_disabled_handlers', serialize(array())));
  $class_list = _migrate_class_list('MigrateDestinationHandler');
  $rows = array();
  $default_values = array();
  foreach ($class_list as $class_name => $handler) {
    $row = array();
    $module = db_select('autoload_registry', 'r')
      ->fields('r', array(
      'module',
    ))
      ->condition('name', $class_name)
      ->condition('type', 'class')
      ->execute()
      ->fetchField();
    $row['module'] = $module;
    $row['class'] = $class_name;
    $row['types'] = implode(', ', $handler
      ->getTypesHandled());
    $default_values[$class_name] = !in_array($class_name, $disabled);
    $rows[$class_name] = $row;
  }
  $build['handlers']['destination']['destination_handlers'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#default_value' => $default_values,
    '#empty' => t('No destination handlers found'),
  );
  $build['handlers']['field'] = array(
    '#type' => 'fieldset',
    '#title' => t('Field handlers'),
    '#collapsible' => TRUE,
  );
  $header = array(
    'module' => array(
      'data' => t('Module'),
    ),
    'class' => array(
      'data' => t('Class'),
    ),
    'types' => array(
      'data' => t('Field types handled'),
    ),
  );
  $class_list = _migrate_class_list('MigrateFieldHandler');
  $rows = array();
  $default_values = array();
  foreach ($class_list as $class_name => $handler) {
    $row = array();
    $module = db_select('autoload_registry', 'r')
      ->fields('r', array(
      'module',
    ))
      ->condition('name', $class_name)
      ->condition('type', 'class')
      ->execute()
      ->fetchField();
    $row['module'] = $module;
    $row['class'] = $class_name;
    $row['types'] = implode(', ', $handler
      ->getTypesHandled());
    $default_values[$class_name] = !in_array($class_name, $disabled);
    $rows[$class_name] = $row;
  }
  $build['handlers']['field']['field_handlers'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#default_value' => $default_values,
    '#empty' => t('No field handlers found'),
  );
  $build['handlers']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save handler statuses'),
    '#submit' => array(
      'migrate_ui_handlers_submit',
    ),
  );
  return $build;
}