You are here

function group_content_wizard_store in Group 8

Same name and namespace in other branches
  1. 2.0.x group.module \group_content_wizard_store()

Stores a content entity from the wizard step 1 in the temp store.

See also

group_form_alter()

\Drupal\group\Entity\Controller\GroupContentController::createForm()

1 string reference to 'group_content_wizard_store'
group_form_alter in ./group.module
Implements hook_form_alter().

File

./group.module, line 612
Allows you to group users, content and other entities.

Code

function group_content_wizard_store($form, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $form_state
    ->getFormObject()
    ->getEntity();

  // Store the unsaved entity in the temp store.
  $store = \Drupal::service('tempstore.private')
    ->get($form_state
    ->get('group_wizard_id'));
  $store_id = $form_state
    ->get('store_id');
  $store
    ->set("{$store_id}:entity", $entity);
  $store
    ->set("{$store_id}:step", 2);

  // Disable any URL-based redirect until the final step.
  $request = \Drupal::service('request_stack')
    ->getCurrentRequest();
  $form_state
    ->setRedirect('<current>', [], [
    'query' => $request->query
      ->all(),
  ]);
  $request->query
    ->remove('destination');
}