Skip to content
Snippets Groups Projects

Cumulative Drupal 9 Compatibility Patches.

Files
3
@@ -6,6 +6,7 @@ use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\ms_ajax_form_example\Manager\StepManager;
use Drupal\ms_ajax_form_example\Step\StepsEnum;
@@ -39,12 +40,20 @@ class MultiStepExampleForm extends FormBase {
*/
protected $stepManager;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* {@inheritdoc}
*/
public function __construct() {
public function __construct(MessengerInterface $messenger = NULL) {
$this->stepId = StepsEnum::STEP_ONE;
$this->stepManager = new StepManager();
$this->messenger = $messenger;
}
/**
@@ -119,7 +128,7 @@ class MultiStepExampleForm extends FormBase {
public function loadStep(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$messages = drupal_get_messages();
$messages = $this->messenger()->all();
if (!empty($messages)) {
// Form did not validate, get messages and render them.
$messages = [
Loading