Drupal 9's architecture allows for seamless integration of services into controllers and forms using dependency injection. Here's a curated list of crucial services that can be effortlessly injected, enhancing the functionality and flexibility of your Drupal 9,10 application:
- Database Services:
- database: Drupal\Core\Database\Connection
- entity_field.manager: Drupal\Core\Entity\EntityFieldManager
- entity_type.manager: Drupal\Core\Entity\EntityTypeManagerInterface
- File Handling Services:
- file_system: Drupal\Core\File\FileSystemInterface
- file.mime_type.guesser: Drupal\Core\File\MimeType\MimeTypeGuesserInterface
- User and Access Services:
- current_user: Drupal\Core\Session\AccountInterface
- access_check.csrf: Drupal\Core\Access\CsrfTokenGeneratorInterface
- access_arguments_resolver_factory: Drupal\Core\Access\AccessArgumentsResolverFactoryInterface
- Configuration Services:
- config.factory: Drupal\Core\Config\ConfigFactoryInterface
- config: Drupal\Core\Config\ConfigManagerInterface
- Routing and Path Services:
- path.validator: Drupal\Core\Routing\RoutePathValidatorInterface
- router.admin_context: Drupal\Core\Routing\AdminContext
- Entity Services:
- entity.repository: Drupal\Core\Entity\EntityRepositoryInterface
- entity_type.bundle.info: Drupal\Core\Entity\EntityTypeBundleInfoInterface
- State Handling Services:
- state: Drupal\Core\State\StateInterface
- keyvalue: Drupal\Core\KeyValueStore\KeyValueFactoryInterface
- Logger and Error Handling Services:
- logger.channel: Drupal\Core\Logger\LoggerChannelInterface
- messenger: Drupal\Core\Messenger\MessengerInterface
- Caching Services:
- cache.backend: Drupal\Core\Cache\CacheBackendInterface
- cache_tags.invalidator: Drupal\Core\Cache\CacheTagsInvalidatorInterface
- Translation Services:
- string_translation: Drupal\Core\StringTranslation\TranslationInterface
- translation_manager: Drupal\Core\StringTranslation\TranslationManagerInterface
- Mail Services:
- mail.manager: Drupal\Core\Mail\MailManagerInterface
- mail: Drupal\Core\Mail\MailManagerInterface (alias for mail.manager)
- Event Dispatching Services:
- event_dispatcher: Symfony\Component\EventDispatcher\EventDispatcherInterface
- entity_display.repository: Drupal\Core\Entity\EntityDisplayRepositoryInterface
- Request and Response Services:
- request_stack: Symfony\Component\HttpFoundation\RequestStack
- current_route_match: Drupal\Core\Routing\RouteMatchInterface
- Theme Services:
- theme.manager: Drupal\Core\Theme\ThemeManagerInterface
- theme_handler: Drupal\Core\Extension\ThemeHandlerInterface
- File Transfer Services:
- file_system: Drupal\Core\File\FileSystemInterface
- stream_wrapper_manager: Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
These services encompass a diverse range of functionalities, aiding in the development of robust and feature-rich Drupal 9, 10 applications. Injecting these services into controllers or forms using dependency injection streamlines development and facilitates seamless integration of various Drupal components.
Add new comment