Review 13.4 Merged

87768[TASK] Add DI alias for ExtensionConfiguration

Stefan Bürk CR +2 V +2 Easy +2 −0 updated 01/14/25, 23:07

Commit message

When services need extension configuration options, and when
these options are not relevant during a potential load/unload
proceduce within extensionmanager, it can be helpful to simplify
injection of single extension configuration values directly.

Previously, the fully qualified class name with three slashes was
required. This update adds an alias to facilitate the use of the
autowire expression. You can now use the alias in the service, for
example:

final readonly class MyClass
{
    public function __construct(
        #[Autowire(expression: 'service("extension-configuration").get("extdemo", "enabled")')]
        protected bool $enabled = false
    ) {
    }

    public function __invoke(): void
    {
        if ($this->enabled === false) {
            return;
        }
    }
}

We should not blindly add aliases for arbitrary services, but
in this case, it can be benefitial to not bloat consuming service
attributes too much. This is mainly side effect free as long as
the configuration option is not relevant during a load/unload
extension operation, which is the case in many cases.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 1

Files 1

Review log 34

  1. Stefan Bürk commented on patch set 1 01/14/25, 22:59

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 01/14/25, 23:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72489

  3. Stefan Bürk voted on patch set 1 CR +2 V +2 01/14/25, 23:07

  4. Stefan Bürk merged patch set 2 01/14/25, 23:07