You are here

function _feeds_form_helper in Feeds 8.2

Same name and namespace in other branches
  1. 7.2 includes/FeedsConfigurable.inc \_feeds_form_helper()

Helper for Feeds validate and submit callbacks.

@todo This is all terrible. Remove.

2 calls to _feeds_form_helper()
feeds_form_submit in ./feeds.module
Submit handler for feeds_form().
feeds_form_validate in ./feeds.module
Validation handler for feeds_form().

File

./feeds.module, line 1291
Feeds - basic API functions and hook implementations.

Code

function _feeds_form_helper($form, &$form_state, $action) {
  $method = $form['#feeds_form_method'] . $action;
  $class = get_class($form['#configurable']);
  $id = $form['#configurable']->id;

  // Re-initialize the configurable object. Using feeds_importer() and
  // feeds_plugin() will ensure that we're using the same instance. We can't
  // reuse the previous form instance because feeds_importer() is used to save.
  // This will re-initialize all of the plugins anyway, causing some tricky
  // saving issues in certain cases.
  // See http://drupal.org/node/1672880.
  if ($class == variable_get('feeds_importer_class', 'Drupal\\feeds\\FeedsImporter')) {
    $form['#configurable'] = feeds_importer($id);
  }
  else {
    $importer = feeds_importer($id);
    $plugin_key = $importer->config[$form['#configurable']
      ->pluginType()]['plugin_key'];
    $form['#configurable'] = feeds_plugin($plugin_key, $id);
  }
  if (method_exists($form['#configurable'], $method)) {
    $form['#configurable']
      ->{$method}($form_state['values']);
  }
}