Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 47547

Use it for questions about the queue of messages displayed to the client.

1 vote

Get the status message string

You don't need to pull the string, you can use the markup object in a string comparision directly: $markup = \Drupal\Core\Render\Markup::create('Test'); if ($markup == 'Test') { // the markup stri …
4uk4's user avatar
  • 102k
2 votes
Accepted

I want to set some error message at one method and display it at another method

It's not about how you set and get the message, although you normally don't get a message but display it in the system message block. The issue is that you can't send a response from inside a Drupal …
4uk4's user avatar
  • 102k
3 votes

How can I change the "page not found" message?

You can do this by overwriting the route system.404 with a custom controller: mymodule/src/Controller/MyHttp4xxController.php <?php namespace Drupal\mymodule\Controller; use Drupal\Core\Controller …
4uk4's user avatar
  • 102k
2 votes

Show form message only on initial load, but not after submit

Try if (empty($form_state->getUserInput())) { $this->messenger()->addWarning('Some info you should know before submitting this form.'); } See the discussions here: Avoid repetitive API calling in …
4uk4's user avatar
  • 102k
7 votes
Accepted

How can I programmatically change a system message?

System messages are stored in a Symfony Flashbag, so there is no need to hack session variables, which can change from version to version. In Drupal 8.5 a new Messenger service was introduced to encap …
4uk4's user avatar
  • 102k
2 votes
Accepted

Is it possible to call response()->setStatusCode() within hook_theme_suggestions_page_alter?

You don't need this code by the way, it is in core since D8.8.x, see https://www.drupal.org/node/2960810. If you want to change the status code then do this in an event subscriber. If you want Drupal …
4uk4's user avatar
  • 102k
1 vote

Show message after redirection

A controller has to return the result, this includes the redirect response. But before you have to set the message: $redirect = new RedirectResponse('/checkout/' . $order_id . '/review'); $this->messe …
4uk4's user avatar
  • 102k