Drupal
class Drupal
Static Service Container wrapper.
Generally, code in Drupal should accept its dependencies via either constructor injection or setter method injection. However, there are cases, particularly in legacy procedural code, where that is infeasible. This class acts as a unified global accessor to arbitrary services within the system in order to ease the transition from procedural code to injected OO code.
The container is built by the kernel and passed in to this class which stores it statically. The container always contains the services from \Drupal\Core\CoreServiceProvider, the service providers of enabled modules and any other service providers defined in $GLOBALS['conf']['container_service_providers'].
This class exists only to support