drupal-services
Installation
SKILL.md
Drupal Services & Dependency Injection
Core Principle
Never use \Drupal::service() in classes — inject via constructor.
Dependency Injection Patterns
Controllers & Forms (ContainerInjectionInterface)
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
final class MyController implements ContainerInjectionInterface {
public function __construct(
private readonly AccountProxyInterface $currentUser,
private readonly EntityTypeManagerInterface $entityTypeManager,
) {}