Problem/Motivation

Follow up from #3221128: Enable service autoconfiguration for core event subscribers

Steps to reproduce

NA

Proposed resolution

Sub-issues:

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Comments

smustgrave created an issue. See original summary.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

duadua’s picture

Potential other tags to enable this for:

  • Cache contexts
  • Cache bins (potentially)
  • Page cache policies
  • Theme negotiators
  • plugin_manager_cache_clear (which has its own autoconfigure logic anyway already in \Drupal\Core\Plugin\PluginManagerPass::process
  • Param converters

One interesting question would be: How can the documentation updates be handled. It seems like it would be best to update the documentation once the story is more coherent.

longwave’s picture

Title: autoconfigure core modules and enable autoconfiguration for other tags » Enable autoconfiguration for other service tags

Narrowing the scope of this, perhaps this can be a discussion issue and then we open child issues when we have determined tags that could be autoconfigured. I opened #3367455: Use service autoconfiguration for all event subscribers for the remaining event subscribers.

longwave’s picture

Implementing this for cache contexts is blocked by #2915594: SessionCacheContext class should implement CacheContextInterface as not all cache contexts currently implement an interface.

duadua’s picture

Narrowing the scope of this, perhaps this can be a discussion issue and then we open child issues when we have determined tags that could be autoconfigured. I opened #3367455: Use service autoconfiguration for all event subscribers for the remaining event subscribers.

That sounds like a really good idea!

Cache contexts

Look at cache contexts there are actually two interfaces involved:

1. \Drupal\Core\Cache\Context\CacheContextInterface
2. \Drupal\Core\Cache\Context\CacheContextsPass

Interesting enough the services then require to start with cache_context., see \Drupal\Core\Cache\Context\CacheContextsPass,
but I don't see a reason why this would block autoconfiguration.

Cache bins (potentially)

Looking at an example:

  cache.page:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin }
    factory: ['@cache_factory', 'get']
    arguments: [page]

Given the additional arguments, it feels like this could be its own issue to discuss it.

Page cache policies

An example of a page cache policy looks like:

    basic_auth.page_cache_request_policy.disallow_basic_auth_requests:
    class: Drupal\basic_auth\PageCache\DisallowBasicAuthRequests
    public: false
    tags:
      - { name: page_cache_request_policy }

This looks like a perfect candidate for autoconfiguration.

Theme negotiators

An example looks like this:

    theme.negotiator.ajax_base_page:
    class: Drupal\Core\Theme\AjaxBasePageNegotiator
    arguments: ['@csrf_token', '@config.factory', '@request_stack']
    tags:
      - { name: theme_negotiator, priority: 1000 }

Theme negotiator seem to care all about priorities. This seems to unqualify them for autoconfiguration. We could introduce an additional attribute.

plugin_manager_cache_clear

This has its own autoconfigure logic anyway already in \Drupal\Core\Plugin\PluginManagerPass::process

Param converters

Looking at an example:

    access_check.entity:
    class: Drupal\Core\Entity\EntityAccessCheck
    tags:
      - { name: access_check, applies_to: _entity_access }

The additional parameter is required. This seems to unqualify them for autoconfiguration. We could introduce an additional attribute.

kim.pepper’s picture

Issue summary: View changes

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.