You are here

function configuration_process_actions in Configuration Management 6

Move through the actions list processing one per call

1 call to configuration_process_actions()
configuration_run_pass in ./configuration.module
Run through a pass of the configuration process

File

./configuration.module, line 328
Provide a unified method for defining site configurations abstracted from their data format. Various data formats should be supported via a plugin architecture such as XML, YAML, JSON, PHP

Code

function configuration_process_actions() {
  $actions =& configuration_get_data('actions');
  $done =& configuration_get_data('actions done');
  if (empty($actions) || !isset($actions[0])) {
    return true;
  }

  // Get the next action
  $action = $actions[0];
  array_shift($actions);

  // If the action here is not set, call the callback to set them
  if (!isset($action[0]) && ($callback = $action[1]->action_callback) && function_exists($callback)) {
    $value = $callback($action[1]->item, $action[1]);
    if (!configuration_get_error() && !isset($value)) {
      $done[] = $action;
      return true;
    }
    if (is_scalar($value)) {
      $value = array(
        $value,
      );
    }

    // Insert the action(s) here and move out so the next calls can handle them
    $context =& $action[1];
    for ($i = count($value) - 1; isset($value[$i]); $i--) {
      $new = array(
        $value[$i],
        &$context,
      );
      array_unshift($actions, $new);
    }
    $done[] = $action;
    return true;
  }
  else {
    if (!isset($action[0])) {
      configuration_set_error('missing action', array(
        '!context' => $action[1],
      ));
    }
  }

  // Process this action
  if (!configuration_get_error() && $action[0]) {
    configuration_process_action($action);
  }

  // Mark this action as complete if no errors
  if (!configuration_get_error()) {
    $done[] = $action;
  }
  else {

    // Put the action back on if there was an error. Maybe the error
    // can be corrected and tried again
    array_unshift($actions, $action);
  }
}