class InjectedService

Same name in other branches
  1. 9 core/modules/system/tests/modules/new_dependency_test/src/InjectedService.php \Drupal\new_dependency_test\InjectedService
  2. 8.9.x core/modules/system/tests/modules/new_dependency_test/src/InjectedService.php \Drupal\new_dependency_test\InjectedService
  3. 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

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 12

Namespace

Drupal\new_dependency_test
View 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

Title Sort descending Modifiers Object type Summary
InjectedService::$service protected property The injected service.
InjectedService::greet public function Get the simple greeting from the service.
InjectedService::__construct public function InjectedService constructor.

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