class TestClassWithSetter
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/DependencyInjection/AutowiredInstanceTraitTest.php \Drupal\Tests\Core\DependencyInjection\TestClassWithSetter
Test class with a setter method for dependency injection.
Hierarchy
- class \Drupal\Tests\Core\DependencyInjection\TestClassWithSetter uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait
Expanded class hierarchy of TestClassWithSetter
File
-
core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ AutowiredInstanceTraitTest.php, line 43
Namespace
Drupal\Tests\Core\DependencyInjectionView 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.