Commit a5f8ce1a authored by idebr's avatar idebr Committed by Berdir
Browse files

Issue #3003373 by idebr, claudiu.cristea, rp7, pookmish, el1_1el, Chris...

Issue #3003373 by idebr, claudiu.cristea, rp7, pookmish, el1_1el, Chris Charlton, Berdir: Wrong verbose messenger method
parent 236d7179
...@@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface; ...@@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\TranslationInterface;
...@@ -20,6 +21,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; ...@@ -20,6 +21,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
*/ */
class PathautoGenerator implements PathautoGeneratorInterface { class PathautoGenerator implements PathautoGeneratorInterface {
use MessengerTrait;
use StringTranslationTrait; use StringTranslationTrait;
/** /**
...@@ -83,7 +85,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -83,7 +85,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
* *
* @var \Drupal\pathauto\MessengerInterface * @var \Drupal\pathauto\MessengerInterface
*/ */
protected $messenger; protected $pathautoMessenger;
/** /**
* The token entity mapper. * The token entity mapper.
...@@ -121,7 +123,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -121,7 +123,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
* The alias storage helper. * The alias storage helper.
* @param AliasUniquifierInterface $alias_uniquifier * @param AliasUniquifierInterface $alias_uniquifier
* The alias uniquifier. * The alias uniquifier.
* @param MessengerInterface $messenger * @param \Drupal\pathauto\MessengerInterface $pathauto_messenger
* The messenger service. * The messenger service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service. * The string translation service.
...@@ -132,14 +134,14 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -132,14 +134,14 @@ class PathautoGenerator implements PathautoGeneratorInterface {
* @param \Drupal\pathauto\AliasTypeManager $alias_type_manager * @param \Drupal\pathauto\AliasTypeManager $alias_type_manager
* Manages pathauto alias type plugins. * Manages pathauto alias type plugins.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, Token $token, AliasCleanerInterface $alias_cleaner, AliasStorageHelperInterface $alias_storage_helper, AliasUniquifierInterface $alias_uniquifier, MessengerInterface $messenger, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mapper, EntityTypeManagerInterface $entity_type_manager, AliasTypeManager $alias_type_manager) { public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, Token $token, AliasCleanerInterface $alias_cleaner, AliasStorageHelperInterface $alias_storage_helper, AliasUniquifierInterface $alias_uniquifier, MessengerInterface $pathauto_messenger, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mapper, EntityTypeManagerInterface $entity_type_manager, AliasTypeManager $alias_type_manager) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->token = $token; $this->token = $token;
$this->aliasCleaner = $alias_cleaner; $this->aliasCleaner = $alias_cleaner;
$this->aliasStorageHelper = $alias_storage_helper; $this->aliasStorageHelper = $alias_storage_helper;
$this->aliasUniquifier = $alias_uniquifier; $this->aliasUniquifier = $alias_uniquifier;
$this->messenger = $messenger; $this->pathautoMessenger = $pathauto_messenger;
$this->stringTranslation = $string_translation; $this->stringTranslation = $string_translation;
$this->tokenEntityMapper = $token_entity_mapper; $this->tokenEntityMapper = $token_entity_mapper;
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
...@@ -234,7 +236,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -234,7 +236,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
$this->aliasUniquifier->uniquify($alias, $source, $langcode); $this->aliasUniquifier->uniquify($alias, $source, $langcode);
if ($original_alias != $alias) { if ($original_alias != $alias) {
// Alert the user why this happened. // Alert the user why this happened.
$this->messenger->addMessage($this->t('The automatically generated alias %original_alias conflicted with an existing alias. Alias changed to %alias.', [ $this->pathautoMessenger->addMessage($this->t('The automatically generated alias %original_alias conflicted with an existing alias. Alias changed to %alias.', [
'%original_alias' => $original_alias, '%original_alias' => $original_alias,
'%alias' => $alias, '%alias' => $alias,
]), $op); ]), $op);
...@@ -362,7 +364,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -362,7 +364,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
$result = $this->createEntityAlias($entity, $op); $result = $this->createEntityAlias($entity, $op);
} }
catch (\InvalidArgumentException $e) { catch (\InvalidArgumentException $e) {
$this->messenger->addError($e->getMessage()); $this->messenger()->addError($e->getMessage());
return NULL; return NULL;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment