diff --git a/src/Form/XmlSitemapDeleteForm.php b/src/Form/XmlSitemapDeleteForm.php
index e5e0dda..4e6f01b 100644
--- a/src/Form/XmlSitemapDeleteForm.php
+++ b/src/Form/XmlSitemapDeleteForm.php
@@ -48,7 +48,7 @@ class XmlSitemapDeleteForm extends EntityConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
- drupal_set_message($this->t('Sitemap %label has been deleted.', ['%label' => $this->entity->label()]));
+ \Drupal::messenger()->addMessage($this->t('Sitemap %label has been deleted.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('xmlsitemap.admin_search');
}
diff --git a/src/Form/XmlSitemapEntitiesSettingsForm.php b/src/Form/XmlSitemapEntitiesSettingsForm.php
index d1d0eb1..2523623 100644
--- a/src/Form/XmlSitemapEntitiesSettingsForm.php
+++ b/src/Form/XmlSitemapEntitiesSettingsForm.php
@@ -156,7 +156,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
'entity' => $entity_type_id,
'bundle' => $bundle,
]),
- 'query' => drupal_get_destination(),
+ 'query' => \Drupal::destination()->getAsArray(),
],
],
],
diff --git a/src/Form/XmlSitemapForm.php b/src/Form/XmlSitemapForm.php
index 318c8bb..fe3cc28 100644
--- a/src/Form/XmlSitemapForm.php
+++ b/src/Form/XmlSitemapForm.php
@@ -74,18 +74,18 @@ class XmlSitemapForm extends EntityForm {
try {
$status = $this->entity->save();
if ($status == SAVED_NEW) {
- drupal_set_message($this->t('Saved the %label sitemap.', [
+ \Drupal::messenger()->addMessage($this->t('Saved the %label sitemap.', [
'%label' => $this->entity->label(),
]));
}
elseif ($status == SAVED_UPDATED) {
- drupal_set_message($this->t('Updated the %label sitemap.', [
+ \Drupal::messenger()->addMessage($this->t('Updated the %label sitemap.', [
'%label' => $this->entity->label(),
]));
}
}
catch (EntityStorageException $ex) {
- drupal_set_message($this->t('There is another sitemap saved with the same context.'), 'error');
+ \Drupal::messenger()->addMessage($this->t('There is another sitemap saved with the same context.'), 'error');
}
$form_state->setRedirect('xmlsitemap.admin_search');
diff --git a/src/Form/XmlSitemapLinkBundleSettingsForm.php b/src/Form/XmlSitemapLinkBundleSettingsForm.php
index 1d8ab07..b8c49e4 100644
--- a/src/Form/XmlSitemapLinkBundleSettingsForm.php
+++ b/src/Form/XmlSitemapLinkBundleSettingsForm.php
@@ -2,9 +2,13 @@
namespace Drupal\xmlsitemap\Form;
+
+use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
+use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
@@ -18,6 +22,14 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
// @codingStandardsIgnoreEnd
/**
+ * The messenger service.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+
+ protected $messenger;
+
+ /**
* {@inheritdoc}
*/
public function getFormId() {
@@ -25,6 +37,31 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
}
/**
+ * Constructs a new XmlSitemapRebuildForm object.
+ *
+ * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+ * The factory for configuration objects.
+ * @param MessengerInterface $messenger
+ * The messenger service.
+ */
+ public function __construct(ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
+ parent::__construct($config_factory);
+
+ $this->messenger = $messenger;
+ $this->config_factory = $config_factory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('config.factory'),
+ $container->get('messenger')
+ );
+ }
+
+ /**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
@@ -41,7 +78,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
if (!$request->isXmlHttpRequest() && $admin_path = xmlsitemap_get_bundle_path($entity, $bundle)) {
// If this is a non-ajax form, redirect to the bundle administration page.
- $destination = drupal_get_destination();
+ $destination = \Drupal::destination()->getAsArray();
$request->query->remove('destination');
$url = Url::fromUri($admin_path, ['query' => [$destination]]);
return new RedirectResponse($url);
@@ -94,7 +131,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
$entity_info = $form['xmlsitemap']['#entity_info'];
if (!empty($form['xmlsitemap']['#show_message'])) {
- drupal_set_message($this->t('XML sitemap settings for the %bundle have been saved.', ['%bundle' => $entity_info['bundles'][$bundle]['label']]));
+ $this->messenger->addMessage($this->t('XML sitemap settings for the %bundle have been saved.', ['%bundle' => $entity_info['bundles'][$bundle]['label']]));
}
// Unset the form values since we have already saved the bundle settings and
diff --git a/src/Form/XmlSitemapRebuildForm.php b/src/Form/XmlSitemapRebuildForm.php
index 375b493..d179b8e 100644
--- a/src/Form/XmlSitemapRebuildForm.php
+++ b/src/Form/XmlSitemapRebuildForm.php
@@ -4,6 +4,7 @@ namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
@@ -22,17 +23,28 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
protected $state;
/**
+ * The messenger service.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+
+ /**
* Constructs a new XmlSitemapRebuildForm object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
+ * @param MessengerInterface $messenger
+ * The messenger service.
*/
- public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state) {
+ public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, MessengerInterface $messenger) {
parent::__construct($config_factory);
$this->state = $state;
+ $this->messenger = $messenger;
}
/**
@@ -41,7 +53,9 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
- $container->get('state')
+ $container->get('state'),
+ $container->get('messenger')
+
);
}
@@ -66,13 +80,13 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
$request = $this->getRequest();
if (!$request->request && !$this->state->get('xmlsitemap_rebuild_needed')) {
if (!$this->state->get('xmlsitemap_regenerate_needed')) {
- drupal_set_message(t('Your sitemap is up to date and does not need to be rebuilt.'), 'error');
+ $this->messenger->addError(t('Your sitemap is up to date and does not need to be rebuilt.'));
}
else {
$request->query->set('destination', 'admin/config/search/xmlsitemap');
- drupal_set_message(t('A rebuild is not necessary. If you are just wanting to regenerate the XML sitemap files, you can run cron manually.', [
- '@link-cron' => Url::fromRoute('system.run_cron', [], ['query' => drupal_get_destination()]),
- ]), 'warning');
+ $this->messenger->addWarning(t('A rebuild is not necessary. If you are just wanting to regenerate the XML sitemap files, you can run cron manually.', [
+ '@link-cron' => Url::fromRoute('system.run_cron', [], ['query' => \Drupal::destination()->getAsArray()]),
+ ]));
$this->setRequest($request);
}
}
diff --git a/src/XmlSitemapGenerator.php b/src/XmlSitemapGenerator.php
index ef133b9..eb4ae66 100644
--- a/src/XmlSitemapGenerator.php
+++ b/src/XmlSitemapGenerator.php
@@ -438,13 +438,13 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
public function regenerateBatchFinished($success, array $results, array $operations, $elapsed) {
if ($success && $this->state->get('xmlsitemap_regenerate_needed') == FALSE) {
$this->state->set('xmlsitemap_generated_last', REQUEST_TIME);
- drupal_set_message(t('The sitemaps were regenerated.'));
+ \Drupal::messenger()->addMessage(t('The sitemaps were regenerated.'));
// Show a watchdog message that the sitemap was regenerated.
$this->logger->notice('Finished XML sitemap generation in @elapsed. Memory usage: @memory-peak.', ['@elapsed' => $elapsed, '@memory-peak' => format_size(memory_get_peak_usage(TRUE))]);
}
else {
- drupal_set_message(t('The sitemaps were not successfully regenerated.'), 'error');
+ \Drupal::messenger()->addError(t('The sitemaps were not successfully regenerated.'));
}
}
@@ -542,10 +542,10 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
*/
public function rebuildBatchFinished($success, array $results, array $operations, $elapsed) {
if ($success && !\Drupal::state()->get('xmlsitemap_rebuild_needed', FALSE)) {
- drupal_set_message(t('The sitemap links were rebuilt.'));
+ \Drupal::messenger()->addMessage(t('The sitemap links were rebuilt.'));
}
else {
- drupal_set_message(t('The sitemap links were not successfully rebuilt.'), 'error');
+ \Drupal::messenger()->addMessage(t('The sitemap links were not successfully rebuilt.'));
}
}
diff --git a/xmlsitemap.module b/xmlsitemap.module
index 3934b7b..47aaf93 100644
--- a/xmlsitemap.module
+++ b/xmlsitemap.module
@@ -555,8 +555,9 @@ function xmlsitemap_clear_directory(XmlSitemapInterface $sitemap = NULL, $delete
function xmlsitemap_directory_move($old_dir, $new_dir, $replace = FILE_EXISTS_REPLACE) {
$success = file_prepare_directory($new_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
- $old_path = drupal_realpath($old_dir);
- $new_path = drupal_realpath($new_dir);
+
+ $old_path = \Drupal::service('file_system')->realpath($old_dir);
+ $new_path = \Drupal::service('file_system')->realpath($new_dir);
if (!is_dir($old_path) || !is_dir($new_path) || !$success) {
return FALSE;
}
@@ -589,7 +590,7 @@ function xmlsitemap_directory_move($old_dir, $new_dir, $replace = FILE_EXISTS_RE
*/
function _xmlsitemap_delete_recursive($path, $delete_root = FALSE) {
// Resolve streamwrapper URI to local path.
- $path = drupal_realpath($path);
+ $path =\Drupal::service('file_system')->realpath($path);
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir->read()) !== FALSE) {
@@ -1123,9 +1124,11 @@ function xmlsitemap_form_submit_flag_regenerate(array $form, FormStateInterface
}
if ($stored_value != 'not_a_variable' && $stored_value != $value) {
\Drupal::state()->set('xmlsitemap_regenerate_needed', TRUE);
- drupal_set_message(t('XML sitemap settings have been modified and the files should be regenerated. You can run cron manually to regenerate the cached files.', [
- '@run-cron' => Url::fromRoute('system.run_cron', [], ['query' => drupal_get_destination()])->toString(),
- ]), 'warning', FALSE);
+ \Drupal::messenger()->addWarning(t('XML sitemap settings have been modified and the files should be regenerated. You can run cron manually to regenerate the cached files.', [
+ '@run-cron' => Url::fromRoute('system.run_cron', [], ['query' => \Drupal::destination()
+ ->getAsArray()])->toString(),
+ ]));
+
return;
}
}
@@ -1181,7 +1184,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
'#suffix' => '',
'#markup' => t('The default XML sitemap settings for this @bundle can be changed here.', [
'@bundle' => Unicode::strtolower($info['bundle label']),
- '@link-type' => Url::fromUri($path, ['query' => drupal_get_destination()])->toString(),
+ '@link-type' => Url::fromUri($path, ['query' => \Drupal::destination()->getAsArray()])->toString(),
]),
];
}
@@ -1306,7 +1309,7 @@ function xmlsitemap_link_bundle_settings_form_submit($form, &$form_state) {
$entity_info = $form['xmlsitemap']['#entity_info'];
if (!empty($form['xmlsitemap']['#show_message'])) {
- drupal_set_message(t('XML sitemap settings for the @bundle-label %bundle have been saved.', ['@bundle-label' => Unicode::strtolower($entity_info['bundle label']), '%bundle' => $entity_info['bundles'][$bundle]['label']]));
+ \Drupal::messenger()->addMessage(t('XML sitemap settings for the @bundle-label %bundle have been saved.', ['@bundle-label' => Unicode::strtolower($entity_info['bundle label']), '%bundle' => $entity_info['bundles'][$bundle]['label']]));
}
// Unset the form values since we have already saved the bundle settings and
@@ -1509,7 +1512,7 @@ function xmlsitemap_get_operation_link($url, $options = []) {
static $destination;
if (!isset($destination)) {
- $destination = drupal_get_destination();
+ $destination = \Drupal::destination()->getAsArray();
}
$link = ['href' => $url] + $options;
@@ -2411,9 +2414,9 @@ function xmlsitemap_check_status() {
'#items' => [$messages],
];
$message = t('One or more problems were detected with your XML sitemap configuration: @messages', ['@messages' => \Drupal::service('renderer')->render($messages)]);
- drupal_set_message($message, 'warning', FALSE);
+ \Drupal::messenger()->addWarning($message);
if (\Drupal::currentUser()->hasPermission('access site reports')) {
- drupal_set_message(t('Check the status report for more information.', ['@status-report' => Url::fromRoute('system.status')->toString()]), 'warning', FALSE);
+ \Drupal::messenger()->addWarning(t('Check the status report for more information.', ['@status-report' => Url::fromRoute('system.status')->toString()]));
}
}
}
diff --git a/xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php b/xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
index 5c7b12f..38fcee3 100644
--- a/xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
+++ b/xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
@@ -7,6 +7,7 @@ use Drupal\Core\Database\Connection;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Http\ClientFactory;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
@@ -55,26 +56,37 @@ class XmlSitemapCustomAddForm extends FormBase {
*/
protected $linkStorage;
- /**
- * Constructs a new XmlSitemapCustomAddForm object.
- *
- * @param \Drupal\Core\Database\Connection $connection
- * The database connection.
- * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
- * The language manager service.
- * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
- * The path alias manager service.
- * @param \Drupal\Core\Http\ClientFactory $http_client_factory
- * A Guzzle client object.
- * @param \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface $link_storage
- * The xmlsitemap link storage service.
- */
- public function __construct(Connection $connection, LanguageManagerInterface $language_manager, AliasManagerInterface $alias_manager, ClientFactory $http_client_factory, XmlSitemapLinkStorageInterface $link_storage) {
+ /**
+ * The messenger service.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+
+ /**
+ * Constructs a new XmlSitemapCustomAddForm object.
+ *
+ * @param \Drupal\Core\Database\Connection $connection
+ * The database connection.
+ * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
+ * The language manager service.
+ * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
+ * The path alias manager service.
+ * @param \Drupal\Core\Http\ClientFactory $http_client_factory
+ * A Guzzle client object.
+ * @param \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface $link_storage
+ * The xmlsitemap link storage service.
+ * @param MessengerInterface $messenger
+ * The messenger service.
+ */
+ public function __construct(Connection $connection, LanguageManagerInterface $language_manager, AliasManagerInterface $alias_manager, ClientFactory $http_client_factory, XmlSitemapLinkStorageInterface $link_storage, MessengerInterface $messenger) {
$this->connection = $connection;
$this->languageManager = $language_manager;
$this->aliasManager = $alias_manager;
$this->httpClientFactory = $http_client_factory;
$this->linkStorage = $link_storage;
+ $this->messenger = $messenger;
}
/**
@@ -86,7 +98,8 @@ class XmlSitemapCustomAddForm extends FormBase {
$container->get('language_manager'),
$container->get('path.alias_manager'),
$container->get('http_client_factory'),
- $container->get('xmlsitemap.link_storage')
+ $container->get('xmlsitemap.link_storage'),
+ $container->get('messenger')
);
}
@@ -243,7 +256,7 @@ class XmlSitemapCustomAddForm extends FormBase {
$form_state->cleanValues();
$link = $form_state->getValues();
$this->linkStorage->save($link);
- drupal_set_message($this->t('The custom link for %loc was saved.', ['%loc' => $link['loc']]));
+ $this->messenger->addMessage($this->t('The custom link for %loc was saved.', ['%loc' => $link['loc']]));
$form_state->setRedirect('xmlsitemap_custom.list');
}
diff --git a/xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php b/xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
index d61ed6a..c3b74da 100644
--- a/xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
+++ b/xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
@@ -3,6 +3,7 @@
namespace Drupal\xmlsitemap_custom\Form;
use Drupal\Core\Form\ConfirmFormBase;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
use Drupal\xmlsitemap\XmlSitemapLinkStorageInterface;
@@ -30,6 +31,9 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
*/
protected $custom_link;
+
+ protected $messenger;
+
/**
* Constructs a new XmlSitemapCustomEditForm object.
*
@@ -38,8 +42,9 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
*
* @codingStandardsIgnoreEnd
*/
- public function __construct(XmlSitemapLinkStorageInterface $link_storage) {
+ public function __construct(XmlSitemapLinkStorageInterface $link_storage, MessengerInterface $messenger) {
$this->linkStorage = $link_storage;
+ $this->messenger = $messenger;
}
/**
@@ -47,7 +52,8 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
*/
public static function create(ContainerInterface $container) {
return new static(
- $container->get('xmlsitemap.link_storage')
+ $container->get('xmlsitemap.link_storage'),
+ $container->get('messenger')
);
}
@@ -98,7 +104,7 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->linkStorage->delete('custom', $this->custom_link['id']);
$this->logger('xmlsitemap')->debug('The custom link for %loc has been deleted.', ['%loc' => $this->custom_link['loc']]);
- drupal_set_message($this->t('The custom link for %loc has been deleted.', ['%loc' => $this->custom_link['loc']]));
+ $this->messenger->addMessage($this->t('The custom link for %loc has been deleted.', ['%loc' => $this->custom_link['loc']]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php b/xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
index a096fc5..fcea0f0 100644
--- a/xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
+++ b/xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\Unicode;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Http\ClientFactory;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
@@ -58,23 +59,33 @@ class XmlSitemapCustomEditForm extends FormBase {
*/
protected $linkStorage;
- /**
- * Constructs a new XmlSitemapCustomEditForm object.
- *
- * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
- * The language manager service.
- * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
- * The path alias manager service.
- * @param \Drupal\Core\Http\ClientFactory $http_client_factory
- * A Guzzle client object.
- * @param \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface $link_storage
- * The xmlsitemap link storage service.
- */
- public function __construct(LanguageManagerInterface $language_manager, AliasManagerInterface $alias_manager, ClientFactory $http_client_factory, XmlSitemapLinkStorageInterface $link_storage) {
+ /**
+ * The alias messenger service.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+ /**
+ * Constructs a new XmlSitemapCustomEditForm object.
+ *
+ * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
+ * The language manager service.
+ * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
+ * The path alias manager service.
+ * @param \Drupal\Core\Http\ClientFactory $http_client_factory
+ * A Guzzle client object.
+ * @param \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface $link_storage
+ * The xmlsitemap link storage service.
+ * @param MessengerInterface $messenger
+ * The messenger service
+ */
+ public function __construct(LanguageManagerInterface $language_manager, AliasManagerInterface $alias_manager, ClientFactory $http_client_factory, XmlSitemapLinkStorageInterface $link_storage, MessengerInterface $messenger) {
$this->languageManager = $language_manager;
$this->aliasManager = $alias_manager;
$this->httpClientFactory = $http_client_factory;
$this->linkStorage = $link_storage;
+ $this->messenger = $messenger;
}
/**
@@ -85,7 +96,8 @@ class XmlSitemapCustomEditForm extends FormBase {
$container->get('language_manager'),
$container->get('path.alias_manager'),
$container->get('http_client_factory'),
- $container->get('xmlsitemap.link_storage')
+ $container->get('xmlsitemap.link_storage'),
+ $container->get('messenger')
);
}
@@ -101,7 +113,8 @@ class XmlSitemapCustomEditForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, $link = '') {
if (!$custom_link = $this->linkStorage->load('custom', $link)) {
- drupal_set_message($this->t('No valid custom link specified.'), 'error');
+ $this->messenger->addError($this->t('No valid custom link specified.'));
+
$this->redirect('xmlsitemap_custom.list');
}
else {
@@ -202,7 +215,7 @@ class XmlSitemapCustomEditForm extends FormBase {
$form_state->cleanValues();
$link = $form_state->getValues();
$this->linkStorage->save($link);
- drupal_set_message($this->t('The custom link for %loc was saved.', ['%loc' => $link['loc']]));
+ \Drupal::messenger()->addMessage($this->t('The custom link for %loc was saved.', ['%loc' => $link['loc']]));
$form_state->setRedirect('xmlsitemap_custom.list');
}