-
-
Save msreis66/3caab217ba9a54609d0caa91a84e553c to your computer and use it in GitHub Desktop.
Patch to update deprecated function druapl_set_message()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git modules/contenta_enhancements/contenta_enhancements.module modules/contenta_enhancements/contenta_enhancements.module | |
index 3269a9e..42910de 100644 | |
--- modules/contenta_enhancements/contenta_enhancements.module | |
+++ modules/contenta_enhancements/contenta_enhancements.module | |
@@ -434,7 +434,7 @@ function contenta_enhancements_form_alter(&$form, FormStateInterface $form_state | |
$form['roles']['widget']['#description'] .= '<br>' . $recommendation_text; | |
if ($form_id === 'consumer_add_form' && empty($form['roles']['widget']['#options'])) { | |
- drupal_set_message($recommendation_text, 'error'); | |
+ \Drupal::messenger()->addMessage($recommendation_text, 'error'); | |
$form['actions']['#disabled'] = TRUE; | |
} | |
} | |
diff --git modules/contenta_enhancements/src/Form/RevertForm.php modules/contenta_enhancements/src/Form/RevertForm.php | |
index 54ec451..e97ecdb 100644 | |
--- modules/contenta_enhancements/src/Form/RevertForm.php | |
+++ modules/contenta_enhancements/src/Form/RevertForm.php | |
@@ -7,6 +7,7 @@ use Drupal\Core\Extension\ModuleInstallerInterface; | |
use Drupal\Core\Extension\ThemeInstallerInterface; | |
use Drupal\Core\Form\ConfirmFormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
+use Drupal\Core\Messenger\MessengerInterface; | |
use Drupal\Core\Url; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
@@ -22,6 +23,11 @@ class RevertForm extends ConfirmFormBase { | |
*/ | |
protected $siteConfig; | |
+ /** | |
+ * @var \Drupal\Core\Messenger\MessengerInterface | |
+ */ | |
+ protected $messenger; | |
+ | |
/** | |
* RevertForm constructor. | |
* | |
@@ -30,9 +36,10 @@ class RevertForm extends ConfirmFormBase { | |
* @param \Drupal\Core\Config\Config $theme_config | |
* @param \Drupal\Core\Config\Config $site_config | |
*/ | |
- public function __construct(ModuleInstallerInterface $module_installer, Config $site_config) { | |
+ public function __construct(ModuleInstallerInterface $module_installer, Config $site_config, MessengerInterface $messenger) { | |
$this->moduleInstaller = $module_installer; | |
$this->siteConfig = $site_config; | |
+ $this->messenger = $messenger; | |
} | |
/** | |
@@ -41,7 +48,8 @@ class RevertForm extends ConfirmFormBase { | |
public static function create(ContainerInterface $container) { | |
return new static( | |
$container->get('module_installer'), | |
- $container->get('config.factory')->getEditable('system.site') | |
+ $container->get('config.factory')->getEditable('system.site'), | |
+ $container->get('messenger') | |
); | |
} | |
@@ -60,7 +68,7 @@ class RevertForm extends ConfirmFormBase { | |
$this->siteConfig->set('page.front', '/admin/content'); | |
$this->siteConfig->save(); | |
$this->moduleInstaller->uninstall(['recipes_magazin']); | |
- drupal_set_message($this->t('Contenta has successfully reverted to a clean state!')); | |
+ $this->messenger()->addMessage($this->t('Contenta has successfully reverted to a clean state!')); | |
$form_state->setRedirectUrl($this->getCancelUrl()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment