You are here

function patterns_execute_action in Patterns 7

Same name and namespace in other branches
  1. 5 patterns.module \patterns_execute_action()
  2. 6.2 patterns.module \patterns_execute_action()
  3. 6 patterns.module \patterns_execute_action()
  4. 7.2 includes/core/common.inc \patterns_execute_action()

Execute an action.

Parameters

mixed $form_id The name of function to call.:

array $form_state The form_state object.:

array $params Extra parameters to be passed to the form function.:

1 call to patterns_execute_action()
patterns_implement_action in includes/core/common.inc
Setup and run an action.

File

includes/core/common.inc, line 297
The common functions used by the Batch and PHP running modes.

Code

function patterns_execute_action($form_id, &$form_state, $params) {

  // Make sure we always have a clear cache for everything.
  // Code taken from drupal_flush_all_caches().
  // Don't clear cache_form - in-progress form submissions may break.
  // Ordered so clearing the page cache will always be the last action.
  $core = array(
    'cache',
    'cache_block',
    'cache_filter',
    'cache_page',
  );
  $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  foreach ($cache_tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  $args = array(
    $form_id,
    &$form_state,
  );
  if (is_array($params)) {
    $args = array_merge($args, $params);
  }
  patterns_executing(TRUE);

  // If we are in batch mode, trick the form api to think
  // otherwise to avoid potential problems

  //$batch =& batch_get();

  //$batch_clone = $batch;

  //$batch = NULL;
  $return = call_user_func_array('drupal_form_submit', $args);

  // TODO: check for errors?
  patterns_executing(FALSE);

  //$batch = $batch_clone;
}