You are here

class ExampleService in Coder 8.2

Same name and namespace in other branches
  1. 8.3 tests/DrupalPractice/Objects/drupal8/ExampleService.php \Drupal\testmodule\ExampleService
  2. 8.3.x tests/DrupalPractice/Objects/drupal8/ExampleService.php \Drupal\testmodule\ExampleService

Some service.

Hierarchy

Expanded class hierarchy of ExampleService

1 string reference to 'ExampleService'
testmodule.services.yml in coder_sniffer/DrupalPractice/Test/Objects/testmodule.services.yml
coder_sniffer/DrupalPractice/Test/Objects/testmodule.services.yml
1 service uses ExampleService
testmodule.example in coder_sniffer/DrupalPractice/Test/Objects/testmodule.services.yml
Drupal\testmodule\ExampleService

File

coder_sniffer/DrupalPractice/Test/Objects/src/ExampleService.php, line 10

Namespace

Drupal\testmodule
View source
class ExampleService {

  /**
   * Using \Drupal here but it should be injected instead.
   */
  public function test() {
    return \Drupal::configFactory();
  }

  /**
   * Loading nodes should be done from an injected service.
   */
  public function test2() {
    return Node::load(1);
  }

  /**
   * t() should not be used, translation service should be injected.
   */
  public function test3() {
    return t('Test');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExampleService::test public function Using \Drupal here but it should be injected instead.
ExampleService::test2 public function Loading nodes should be done from an injected service.
ExampleService::test3 public function t() should not be used, translation service should be injected.