function TestClassWithSetter::setService

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/DependencyInjection/AutowiredInstanceTraitTest.php \Drupal\Tests\Core\DependencyInjection\TestClassWithSetter::setService()

Attributes

#[Required]

File

core/tests/Drupal/Tests/Core/DependencyInjection/AutowiredInstanceTraitTest.php, line 52

Class

TestClassWithSetter
Test class with a setter method for dependency injection.

Namespace

Drupal\Tests\Core\DependencyInjection

Code

public function setService(#[Autowire(service: 'my_service')] $service) : void {
  $this->injectedService = $service;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.