Problem/Motivation
In #3416522: Add the ability to install multiple modules and only do a single container rebuild to ModuleInstaller we installing modules without rebuilding the container all the time. To do this we need to be able to reset the container so that any instantiated services can be re-instantiated. Unfortunately this runs into 2 problems:
- \Drupal\Component\DependencyInjection\Container::reset() doesn't recreate the 'service_container' entry that was added in the constructor
- We need an equivalent of \Drupal\Core\DrupalKernel::initializeContainer() that copies stuff from the old container to the new container - think synthetic services, logged in user and session.
Proposed resolution
- Fix Container::reset() by not settings the circular reference but doing what Symfony does and adding hard coded 'service_container' in a few places
- Add DrupalKernel::resetContainer()
Remaining tasks
User interface changes
None
API changes
New \Drupal\Core\DrupalKernel::resetContainer()
Data model changes
None
Release notes snippet
N/a