Commit b6419ea0 authored by Luca Lusso's avatar Luca Lusso Committed by Moshe Weitzman
Browse files

Issue #3032580 by akshay_d, lussoluca: drupal_set_message() is deprecated

parent 5fffecd6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class DevelController extends ControllerBase {
   */
  public function cacheClear() {
    drupal_flush_all_caches();
    drupal_set_message('Cache cleared.');
    $this->messenger()->addMessage($this->t('Cache cleared.'));
    return $this->redirect('<front>');
  }

+3 −2
Original line number Diff line number Diff line
@@ -177,7 +177,8 @@ class RouteInfoController extends ControllerBase {
        $route = $this->router->match($path);
      }
      catch (\Exception $e) {
        drupal_set_message($this->t("Unable to load route for url '%url'", ['%url' => $path]), 'warning');
        $this->messenger()->addWarning($this->t("Unable to load route for url '%url'", ['%url' => $path]));

      }
    }

@@ -188,7 +189,7 @@ class RouteInfoController extends ControllerBase {
        $route = $this->routeProvider->getRouteByName($route_name);
      }
      catch (\Exception $e) {
        drupal_set_message($this->t("Unable to load route '%name'", ['%name' => $route_name]), 'warning');
        $this->messenger()->addWarning($this->t("Unable to load route '%name'", ['%name' => $route_name]));
      }
    }

+4 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\devel;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

@@ -12,6 +13,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
class DevelDumperManager implements DevelDumperManagerInterface {

  use StringTranslationTrait;
  use MessengerTrait;

  /**
   * The devel config.
@@ -91,7 +93,7 @@ class DevelDumperManager implements DevelDumperManagerInterface {
  public function message($input, $name = NULL, $type = 'status', $plugin_id = NULL) {
    if ($this->hasAccessToDevelInformation()) {
      $output = $this->export($input, $name, $plugin_id);
      drupal_set_message($output, $type, TRUE);
      $this->messenger()->addStatus($output);
    }
  }

@@ -103,7 +105,7 @@ class DevelDumperManager implements DevelDumperManagerInterface {
    // The temp directory does vary across multiple simpletest instances.
    $file = file_directory_temp() . '/drupal_debug.txt';
    if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this->hasAccessToDevelInformation()) {
      drupal_set_message($this->t('Devel was unable to write to %file.', ['%file' => $file]), 'error');
      $this->messenger()->addError($this->t('Devel was unable to write to %file.', ['%file' => $file]));
      return FALSE;
    }
  }
+4 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\devel\EventSubscriber;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
@@ -18,6 +19,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
class ThemeInfoRebuildSubscriber implements EventSubscriberInterface {

  use StringTranslationTrait;
  use MessengerTrait;

  /**
   * Internal flag for handle user notification.
@@ -99,7 +101,8 @@ class ThemeInfoRebuildSubscriber implements EventSubscriberInterface {
      if ($session && !$session->has($this->notificationFlag)) {
        $session->set($this->notificationFlag, TRUE);
        $message = $this->t('The theme information is being rebuilt on every request. Remember to <a href=":url">turn off</a> this feature on production websites.', [':url' => Url::fromRoute('devel.admin_settings')->toString()]);
        drupal_set_message($message, 'warning', TRUE);
        $this->messenger()->addWarning($message);

      }
    }
  }
+5 −5
Original line number Diff line number Diff line
@@ -28,14 +28,14 @@ class ConfigEditor extends FormBase {
    $config = $this->config($config_name);

    if ($config === FALSE || $config->isNew()) {
      drupal_set_message(t('Config @name does not exist in the system.', array('@name' => $config_name)), 'error');
      $this->messenger()->addError($this->t('Config @name does not exist in the system.', array('@name' => $config_name)));
      return;
    }

    $data = $config->getOriginal();

    if (empty($data)) {
      drupal_set_message(t('Config @name exists but has no data.', array('@name' => $config_name)), 'warning');
      $this->messenger()->addWarning($this->t('Config @name exists but has no data.', array('@name' => $config_name)));
      return;
    }

@@ -43,7 +43,7 @@ class ConfigEditor extends FormBase {
      $output = Yaml::encode($data);
    }
    catch (InvalidDataTypeException $e) {
      drupal_set_message(t('Invalid data detected for @name : %error', array('@name' => $config_name, '%error' => $e->getMessage())), 'error');
      $this->messenger()->addError($this->t('Invalid data detected for @name : %error', array('@name' => $config_name, '%error' => $e->getMessage())));
      return;
    }

@@ -112,13 +112,13 @@ class ConfigEditor extends FormBase {
    $values = $form_state->getValues();
    try {
      $this->configFactory()->getEditable($values['name'])->setData($values['parsed_value'])->save();
      drupal_set_message($this->t('Configuration variable %variable was successfully saved.', array('%variable' => $values['name'])));
      $this->messenger()->addMessage($this->t('Configuration variable %variable was successfully saved.', array('%variable' => $values['name'])));
      $this->logger('devel')->info('Configuration variable %variable was successfully saved.', array('%variable' => $values['name']));

      $form_state->setRedirectUrl(Url::fromRoute('devel.configs_list'));
    }
    catch (\Exception $e) {
      drupal_set_message($e->getMessage(), 'error');
      $this->messenger()->addError($e->getMessage());
      $this->logger('devel')->error('Error saving configuration variable %variable : %error.', array('%variable' => $values['name'], '%error' => $e->getMessage()));
    }
  }
Loading