public static function OpignoModuleManagerController::ajaxFormEntityCallback in Opigno module 3.x
Same name and namespace in other branches
- 8 src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::ajaxFormEntityCallback()
Ajax form callback.
File
- src/Controller/ OpignoModuleManagerController.php, line 170 
Class
- OpignoModuleManagerController
- Controller for all the actions of the Opigno module manager.
Namespace
Drupal\opigno_module\ControllerCode
public static function ajaxFormEntityCallback(&$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  // If errors, returns the form with errors and messages.
  if ($form_state
    ->hasAnyErrors()) {
    return $form;
  }
  $entity = $form_state
    ->getBuildInfo()['callback_object']
    ->getEntity();
  $item = [];
  $item['id'] = $entity
    ->id();
  $item['name'] = $entity
    ->getName();
  $command = new SettingsCommand([
    'formValues' => $item,
    'messages' => \Drupal::messenger()
      ->all(),
  ], TRUE);
  \Drupal::messenger()
    ->deleteAll();
  $response
    ->addCommand($command);
  return $response;
}