You are here

public function ExampleClassWithDependencyInjection::test2 in Coder 8.3.x

Same name and namespace in other branches
  1. 8.3 tests/DrupalPractice/Objects/drupal8/ExampleClassWithDependencyInjection.php \Drupal\testmodule\ExampleClassWithDependencyInjection::test2()

Loading nodes directly is not allowed, we should use an injected service.

File

tests/DrupalPractice/Objects/drupal8/ExampleClassWithDependencyInjection.php, line 23

Class

ExampleClassWithDependencyInjection
A class which is not a service but has access to the container.

Namespace

Drupal\testmodule

Code

public function test2() {
  return Node::load(1);
}