class TestClassWithSetter

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

Test class with a setter method for dependency injection.

Hierarchy

Expanded class hierarchy of TestClassWithSetter

File

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

Namespace

Drupal\Tests\Core\DependencyInjection
View source
class TestClassWithSetter {
  use AutowiredInstanceTrait;
  
  /**
   * The injected service.
   */
  public \stdClass $injectedService;
  public function setService(#[Autowire(service: 'my_service')] $service) : void {
    $this->injectedService = $service;
  }

}

Members

Title Sort descending Modifiers Object type Summary
AutowiredInstanceTrait::createInstanceAutowired public static function Instantiates a new instance of the implementing class using autowiring.
AutowiredInstanceTrait::getAutowireArguments private static function Resolves arguments for a method using autowiring.
TestClassWithSetter::$injectedService public property The injected service.
TestClassWithSetter::setService public function #[Required]

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