toolbar_plus-1.0.x-dev/modules/toolbar_plus_entity_workflow/toolbar_plus_entity_workflow.module

modules/toolbar_plus_entity_workflow/toolbar_plus_entity_workflow.module
<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function toolbar_plus_entity_workflow_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if (in_array($form_id, ['wse_workspace_switcher_form', 'workspace_switcher_form'])) {
    $form['#submit'][] = 'toolbar_plus_entity_workflow_form_workspace_switcher_form_submit';
  }
}
/**
 * Workspace switcher submission handler.
 */
function toolbar_plus_entity_workflow_form_workspace_switcher_form_submit(&$form, FormStateInterface $form_state) {
  $redirect_destination = \Drupal::destination()->get();
  // Change the redirect destination back to the canonical page when the
  // destination was toolbar_plus.load_editable_page (our AJAX re-loader).
  if (str_contains($redirect_destination, '/toolbar-plus/load-editable-page/')) {
    $pieces = explode('/', $redirect_destination);
    $entity = \Drupal::entityTypeManager()->getStorage($pieces[3])->load($pieces[4]);
    $form_state->setRedirectUrl($entity->toUrl());
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc