Problem/Motivation

  • Replace deprecated \Drupal::entityQuery;
  • Injection service plugin.manager.alias_type (Drupal\pathauto\AliasTypeManager );

Comments

thalles created an issue. See original summary.

thalles’s picture

Status: Needs work » Needs review
StatusFileSize
new4.56 KB

Follow the patch!

idebr’s picture

Status: Needs review » Needs work
  1. +++ b/pathauto.services.yml
    @@ -1,7 +1,7 @@
     services:
       pathauto.generator:
         class: Drupal\pathauto\PathautoGenerator
    -    arguments: ['@config.factory', '@module_handler', '@token', '@pathauto.alias_cleaner', '@pathauto.alias_storage_helper', '@pathauto.alias_uniquifier', '@pathauto.verbose_messenger', '@string_translation', '@token.entity_mapper', '@entity_type.manager']
    +    arguments: ['@config.factory', '@module_handler', '@token', '@pathauto.alias_cleaner', '@pathauto.alias_storage_helper', '@pathauto.alias_uniquifier', '@pathauto.verbose_messenger', '@string_translation', '@token.entity_mapper', '@entity_type.manager', '@plugin.manager.alias_type']
    

    Let's add an empty post_update hook so the services container is rebuilt, see \taxonomy_post_update_clear_entity_bundle_field_definitions_cache() for an example. Existing sites will trigger an error: ArgumentCountError: Too few arguments to function Drupal\pathauto\PathautoGenerator::__construct()

  2. +++ b/src/PathautoGenerator.php
    @@ -134,6 +143,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
    +    $this->aliasTypeManager = $plugin_manager_alias_type;
    

    Let's use $alias_type_manager for consistency with the other variables.

berdir’s picture

1. I'm not that fond of the empty post update pattern, we could for BC just make the arguments optional and fall back to \Drupal::service() in the constructor, then it will work fine too.

thalles’s picture

Status: Needs work » Needs review
StatusFileSize
new4.54 KB
new1.82 KB

Follow the new patch!

  • Berdir committed 236d717 on 8.x-1.x authored by thalles
    Issue #3031650 by thalles: Injection on PathautoGenerator
    
berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.