relationship between environment_indicator entities and settings.php values

Created on 5 March 2024, about 1 year ago
Updated 11 March 2024, about 1 year ago

Problem/Motivation

It seems a bit weird that you define multiple environments as environment_indicator entities, but then which environment is current comes from a totally different place.

Why not allow settings.php to be omitted, and then detect which of the environment_indicator entities' domain matches the current request?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joachim
  • πŸ‡¬πŸ‡§United Kingdom joachim

    This works for getting the entity that's the current site:

          $request = \Drupal::request();
          $entities = \Drupal::entityTypeManager()->getStorage('environment_indicator')->loadByProperties([
            'url' => $request->getSchemeAndHttpHost(),
          ]);
          if ($entities) {
            $this->current = reset($entities);
          }
    

    What needs to be worked out is how is should function -- should a entity be looked for only if there is no environment_indicator.indicator config?

  • πŸ‡ΊπŸ‡ΈUnited States devkinetic

    I've put work into this topic over on πŸ“Œ Implement the current environment as a service and utilize plugins Active where current environment becomes a service and added a plugin manager to define the method of detecting the current environment. This way you can use whatever method you like, configure it, or even develop your own for more advanced scenarios. Unfortunately, it has not gotten any traction or feedback.

Production build 0.71.5 2024