class InjectedService in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/new_dependency_test/src/InjectedService.php \Drupal\new_dependency_test\InjectedService
- 10 core/modules/system/tests/modules/new_dependency_test/src/InjectedService.php \Drupal\new_dependency_test\InjectedService
Generic service with a dependency on a service defined in a new module.
Hierarchy
- class \Drupal\new_dependency_test\InjectedService
Expanded class hierarchy of InjectedService
1 string reference to 'InjectedService'
- new_dependency_test.services.yml in core/
modules/ system/ tests/ modules/ new_dependency_test/ new_dependency_test.services.yml - core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml
1 service uses InjectedService
- new_dependency_test.dependent in core/
modules/ system/ tests/ modules/ new_dependency_test/ new_dependency_test.services.yml - Drupal\new_dependency_test\InjectedService
File
- core/
modules/ system/ tests/ modules/ new_dependency_test/ src/ InjectedService.php, line 10
Namespace
Drupal\new_dependency_testView source
class InjectedService {
/**
* The injected service.
*
* @var \Drupal\new_dependency_test_with_service\NewService
*/
protected $service;
/**
* InjectedService constructor.
*
* @param \Drupal\new_dependency_test_with_service\NewService $service
* The service of the new module.
*/
public function __construct(NewService $service) {
$this->service = $service;
}
/**
* Get the simple greeting from the service.
*
* @return string
* The greeting.
*/
public function greet() {
return $this->service
->greet();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InjectedService:: |
protected | property | The injected service. | |
InjectedService:: |
public | function | Get the simple greeting from the service. | |
InjectedService:: |
public | function | InjectedService constructor. |