3 namespace Drupal\pathauto;
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Messenger\MessengerInterface as CoreMessengerInterface;
7 use Drupal\Core\Session\AccountInterface;
10 * Provides a verbose messenger.
12 class VerboseMessenger implements MessengerInterface {
24 * @var \Drupal\Core\Config\ConfigFactoryInterface
26 protected $configFactory;
29 * The current user account.
31 * @var \Drupal\Core\Session\AccountInterface
36 * The messenger service.
38 * @var \Drupal\Core\Messenger\MessengerInterface
43 * Creates a verbose messenger.
45 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
47 * @param \Drupal\Core\Session\AccountInterface $account
48 * The current user account.
49 * @param \Drupal\Core\Messenger\MessengerInterface $messenger
50 * The messenger service.
52 public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $account, CoreMessengerInterface $messenger) {
53 $this->configFactory = $config_factory;
54 $this->account = $account;
55 $this->messenger = $messenger;
61 public function addMessage($message, $op = NULL) {
63 if (!isset($this->isVerbose)) {
64 $config = $this->configFactory->get('pathauto.settings');
65 $this->isVerbose = $config->get('verbose') && $this->account->hasPermission('notify of path changes');
68 if (!$this->isVerbose || (isset($op) && in_array($op, array('bulkupdate', 'return')))) {
73 $this->messenger->addMessage($message);