Commit 6b8207ef authored by ilcho.vuchkov's avatar ilcho.vuchkov
Browse files

Issue #3076579 by ilchovuchkov: Replace drupal_set_message() with DI in DefaultForm.

parent a500d8b9
Loading
Loading
Loading
Loading
+34 −1
Changes for src/Form/DefaultForm.php: 34 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@

namespace Drupal\notify\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormStateInterface;

@@ -11,6 +14,36 @@ use Drupal\Core\Form\FormStateInterface;
 */
class DefaultForm extends ConfigFormBase {

  /**
   * Drupal\Core\Messenger\MessengerInterface definition.
   *
   * @var \Drupal\Core\Messenger\MessengerInterface
   */
  protected $messenger;

  /**
   * Class constructor.
   *
   * @param ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param MessengerInterface $messenger
   *   The core messenger service.
   */
  public function __construct(ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
    parent::__construct($config_factory);
    $this->messenger = $messenger;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('messenger')
    );
  }

  /**
   * {@inheritdoc}
   */
@@ -123,7 +156,7 @@ class DefaultForm extends ConfigFormBase {
      ->set('notify_def_teasers', $values['teasers'])
      ->set('notify_nodetypes', $values['notify_nodetypes'])
      ->save();
    drupal_set_message(t('Notify default settings saved.'));
    $this->messenger->addMessage(t('Notify default settings saved.'));
  }

}
+1
Changes for src/Form/QueueForm.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface;
 * Defines a form that configures forms module settings.
 */
class QueueForm extends ConfigFormBase {

  /**
   * Drupal\Core\Messenger\MessengerInterface definition.
   *