setBackendConfig should initiate the backend plugin and always call setConfiguration

Created on 1 April 2025, 2 months ago

Problem/Motivation

When calling setBackendConfig, the backend plugin has no way to react to the configuration change unless it has been initialized.

  #[ActionMethod(adminLabel: new TranslatableMarkup('Set backend config'), pluralize: FALSE)]
  public function setBackendConfig(array $backend_config) {
    $this->backend_config = $backend_config;
    // In case the backend plugin is already loaded, make sure the configuration
    // stays in sync.
    if ($this->backendPlugin
        && $this->getBackend()->getConfiguration() !== $backend_config) {
      $this->getBackend()->setConfiguration($backend_config);
    }
    return $this;
  }

Steps to reproduce

See Determine host, context, and core from update_endpoint on setConfiguration as well Active using a recipe to set configuration for SearchStax using inputs and setBackendConfig

Proposed resolution

Always load the backend plugin and set its configuration

  #[ActionMethod(adminLabel: new TranslatableMarkup('Set backend config'), pluralize: FALSE)]
  public function setBackendConfig(array $backend_config) {
    $this->getBackend()->setConfiguration($backend_config);
    $this->backend_config = $this->getBackend()->getConfiguration();
    return $this;
  }

Remaining tasks

Feature request
Status

Active

Version

1.0

Component

General code

Created by

🇺🇸United States mglaman WI, USA

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024