Retrieves the Drupal Container to standardize object construction.
The container is built by the kernel and passed in to this function which stores it statically. The container always contains the services from \Drupal\Core\CoreBundle, the bundles of enabled modules and any other bundles defined in $GLOBALS['conf']['container_bundles'].
Symfony\Component\DependencyInjection\Container $new_container: (optional) A new container instance to replace the current.
Symfony\Component\DependencyInjection\Container|bool The instance of the Container used to set up and maintain object instances or FALSE if none exist yet.
function drupal_container(Container $new_container = NULL) {
// We do not use drupal_static() here because we do not have a mechanism by
// which to reinitialize the stored objects, so a drupal_static_reset() call
// would leave Drupal in a nonfunctional state.
static $container;
if (isset($new_container)) {
$container = $new_container;
}
return $container;
}