You are here

class SetterInjection in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/new_dependency_test/src/SetterInjection.php \Drupal\new_dependency_test\SetterInjection

Generic service which uses setter injection.

Hierarchy

Expanded class hierarchy of SetterInjection

1 string reference to 'SetterInjection'
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 SetterInjection
new_dependency_test.setter_injection in core/modules/system/tests/modules/new_dependency_test/new_dependency_test.services.yml
Drupal\new_dependency_test\SetterInjection

File

core/modules/system/tests/modules/new_dependency_test/src/SetterInjection.php, line 10

Namespace

Drupal\new_dependency_test
View source
class SetterInjection {

  /**
   * The injected service.
   *
   * @var \Drupal\new_dependency_test_with_service\NewService
   */
  protected $service;

  /**
   * SetterInjection constructor.
   *
   * @param \Drupal\new_dependency_test_with_service\NewService $service
   *   The service of the new module.
   */
  public function setter(NewService $service) {
    $this->service = $service;
  }

  /**
   * Get the simple greeting from the service.
   *
   * @return string
   *   The greeting.
   */
  public function greet() {
    return $this->service
      ->greet();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SetterInjection::$service protected property The injected service.
SetterInjection::greet public function Get the simple greeting from the service.
SetterInjection::setter public function SetterInjection constructor.