Services and Dependency Injection Container

Overview of the Dependency Injection Container and Services. Overview of container, injection, and services The Services and Dependency Injection Container concepts have been adopted by Drupal from the Symfony framework. A "service" (such as accessing the database, sending email, or translating user interface text) is defined (given a name and an interface or at least a class that defines the methods that may be called), and a default class is designated to provide the service. These two steps

ServiceProviderBase::register

public ServiceProviderBase::register(ContainerBuilder $container) Registers services to the container. Parameters ContainerBuilder $container: The ContainerBuilder to register services to. Overrides ServiceProviderInterface::register File core/lib/Drupal/Core/DependencyInjection/ServiceProviderBase.php, line 15 Class ServiceProviderBase Base service provider implementation. Namespace Drupal\Core\DependencyInjection Code public function register(ContainerBuilder $container) { }

ServiceProviderBase

Base service provider implementation. Hierarchy class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface Related topics Services and Dependency Injection Container Overview of the Dependency Injection Container and Services. File core/lib/Drupal/Core/DependencyInjection/ServiceProviderBase.php, line 10 Namespace Drupal\Core\DependencyInjection Members Name Modifiers Type Description ServiceProviderBase::alter

ServiceModifierInterface

Interface that service providers can implement to modify services. Hierarchy interface \Drupal\Core\DependencyInjection\ServiceModifierInterface Related topics Services and Dependency Injection Container Overview of the Dependency Injection Container and Services. File core/lib/Drupal/Core/DependencyInjection/ServiceModifierInterface.php, line 10 Namespace Drupal\Core\DependencyInjection Members Name Modifiers Type Description ServiceModifierInterface::alter public funct

ServiceProviderBase::alter

public ServiceProviderBase::alter(ContainerBuilder $container) Modifies existing service definitions. Parameters ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered. Overrides ServiceModifierInterface::alter File core/lib/Drupal/Core/DependencyInjection/ServiceProviderBase.php, line 21 Class ServiceProviderBase Base service provider implementation. Namespace Drupal\Core\DependencyInjection Code public function alter(ContainerBuilder $container) {

ServiceModifierInterface::alter

public ServiceModifierInterface::alter(ContainerBuilder $container) Modifies existing service definitions. Parameters ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered. File core/lib/Drupal/Core/DependencyInjection/ServiceModifierInterface.php, line 18 Class ServiceModifierInterface Interface that service providers can implement to modify services. Namespace Drupal\Core\DependencyInjection Code public function alter(ContainerBuilder $container)

SerializationServiceProvider::register

public SerializationServiceProvider::register(ContainerBuilder $container) Registers services to the container. Parameters ContainerBuilder $container: The ContainerBuilder to register services to. Overrides ServiceProviderInterface::register File core/modules/serialization/src/SerializationServiceProvider.php, line 16 Class SerializationServiceProvider Serialization dependency injection container. Namespace Drupal\serialization Code public function register(ContainerBuilder $containe

Service Tags

Service tags overview Some services have tags, which are defined in the service definition. Tags are used to define a group of related services, or to specify some aspect of how the service behaves. Typically, if you tag a service, your service class must also implement a corresponding interface. Some common examples: access_check: Indicates a route access checking service; see the Menu and routing system topic for more information. cache.bin: Indicates a cache bin service; see the Cache topi

SerializationServiceProvider

Serialization dependency injection container. Hierarchy class \Drupal\serialization\SerializationServiceProvider implements ServiceProviderInterface File core/modules/serialization/src/SerializationServiceProvider.php, line 11 Namespace Drupal\serialization Members Name Modifiers Type Description SerializationServiceProvider::register public function Registers services to the container. Overrides ServiceProviderInterface::register

SerializationInterface::getFileExtension

public static SerializationInterface::getFileExtension() Gets the file extension for this serialization format. Return value string The file extension, without leading dot. File core/lib/Drupal/Component/Serialization/SerializationInterface.php, line 38 Class SerializationInterface Defines an interface for serialization formats. Namespace Drupal\Component\Serialization Code public static function getFileExtension();