summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php')
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php b/core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php
index aa50cc4..65e1372 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php
@@ -6,6 +6,7 @@ use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -28,6 +29,13 @@ class AjaxFormBlock extends BlockBase implements FormInterface, ContainerFactory
protected $formBuilder;
/**
+ * The messenger.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+ /**
* Constructs a new AjaxFormBlock.
*
* @param array $configuration
@@ -38,10 +46,13 @@ class AjaxFormBlock extends BlockBase implements FormInterface, ContainerFactory
* The plugin implementation definition.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
+ * @param \Drupal\Core\Messenger\MessengerInterface $messenger
+ * The messenger.
*/
- public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder) {
+ public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $form_builder;
+ $this->messenger = $messenger;
}
/**
@@ -52,7 +63,8 @@ class AjaxFormBlock extends BlockBase implements FormInterface, ContainerFactory
$configuration,
$plugin_id,
$plugin_definition,
- $container->get('form_builder')
+ $container->get('form_builder'),
+ $container->get('messenger')
);
}
@@ -129,7 +141,7 @@ class AjaxFormBlock extends BlockBase implements FormInterface, ContainerFactory
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message('Submission successful.');
+ $this->messenger->addStatus('Submission successful.');
}
}