Setting messages from classes in Drupal How do we set messages now in 8.x? Do we still use drupal_set_message? Not a fan of mixing procedural calls within classes if it can be avoided.
Prior to 8.5.x, drupal_set_message is the way.
For &gt;=8.5.0-alpha1, there's a new messenger service, with a note (and example which I won't bother copying):

The procedural functions drupal_set_message() and drupal_get_messages() have been deprecated and replaced with a dedicated Messenger service.
You should now inject this service as a dependency for your own services and controllers: