Problem/Motivation
In https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
/**
* Changes parameters in the services.yml file.
*
* @param string $name
* The name of the parameter.
* @param string $value
* The value of the parameter.
*/
protected function setContainerParameter($name, $value) {
$filename = $this->siteDirectory . '/services.yml';
chmod($filename, 0666);
$services = Yaml::decode(file_get_contents($filename));
$services['parameters'][$name] = $value;
file_put_contents($filename, Yaml::encode($services));
// Ensure that the cache is deleted for the yaml file loader.
$file_cache = FileCacheFactory::get('container_yaml_loader');
$file_cache->delete($filename);
}
The $value type is string, but it can be anything and most of the time it is already an array that is passed. Example:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/syste...
// Enable debug, rebuild the service container, and clear all caches.
$parameters = $this->container->getParameter('twig.config');
$parameters['debug'] = TRUE;
$this->setContainerParameter('twig.config', $parameters);
Proposed resolution
Fix the type to be mixed or array|string?
Remaining tasks
- Decide of a solution
- Implement it