How to properly inject mutable config to the controller? Apparently by default ControllerBase::config() returns \Drupal\Core\Config\ImmutableConfig object. How can I instantiate the controller class to make it use \Drupal\Core\Config\Config instead (which is mutable)?

I know I can do this inside the controller:

$config = \Drupal::service('config.factory')-&gt;getEditable('loremipsum');


However this is not the nicest solution. Besides, is there any reason for using ImmutableConfig by default?
There are two other ways to inject dependencies into a controller, and a third alternative.

1. Implement ContainerInjectionInterface

This does technically add a dependency to the container. In a unit test, the container would need to be set with \Drupal::setContainer() with a mock object of the config factory and config object.

`

  public static function create(\Symfony\Component\DependencyInjection\ContainerInterface $container) {
    return new static($container-&gt;get('config.factory'));
  }

  public function __construct(\Drupal\Core\Config\ConfigFactoryInterface $config_factory) {
    $config = $this-&gt;config_factory-&gt;getEditable('loremipsum');
  }


`

2. Make the controller a service.

This is recommended by all of the Symfony developers that I have asked, and none have been concerned by any performance impact of making all of Drupal's routes use services.

This is subjective, and there is some contention about the practice.

3. Use a Form class that extends ConfigFormBase instead.

But, why would a controller want MutableConfig instead of ImmutableConfig? A Form class extending ConfigFormBase instead. A form is probably the best place to modify configuration values such as a class that extends ConfigFormBase.