You are here

function backstretch_context_reaction_backstretch::options_form_submit in Backstretch 7.2

Same name and namespace in other branches
  1. 7 plugins/backstretch_context_reaction_backstretch.inc \backstretch_context_reaction_backstretch::options_form_submit()

Options form submit handler.

Overrides context_reaction::options_form_submit

File

plugins/backstretch_context_reaction_backstretch.inc, line 265
Backstretch reaction class for Context integration.

Class

backstretch_context_reaction_backstretch
@file Backstretch reaction class for Context integration.

Code

function options_form_submit($values) {

  // Modify settings if entity was selected as source.
  if ($values['source']['type'] == 'entity') {
    $entity_type = $values['source']['entity']['entity_type'];

    // Move the field setting for non file entity types.
    if ($entity_type != 'file') {
      $values['source']['entity']['field'] = $values['source']['entity'][$entity_type]['field'];
    }

    // Remove all unnecessary settings from the values.
    foreach ($values['source']['entity'] as $key => $value) {
      if (!in_array($key, array(
        'entity_type',
        'ids',
        'field',
      ))) {
        unset($values['source']['entity'][$key]);
      }
    }
  }
  return $values;
}