class ExampleClass in Coder 8.3.x
Same name and namespace in other branches
- 8.3 tests/DrupalPractice/Objects/drupal8/ExampleClass.php \Drupal\testmodule\ExampleClass
A class which is not a service.
Hierarchy
- class \Drupal\testmodule\ExampleClass
Expanded class hierarchy of ExampleClass
File
- tests/
DrupalPractice/ Objects/ drupal8/ ExampleClass.php, line 10
Namespace
Drupal\testmoduleView source
class ExampleClass {
/**
* Using \Drupal here is allowed since this class cannot access the container.
*/
public function test() {
return \Drupal::configFactory();
}
/**
* Loading nodes directly is allowed since we cannot access the container.
*/
public function test2() {
return Node::load(1);
}
/**
* Global function is allowed since we cannot access the container.
*/
public function test3() {
return format_date(time());
}
/**
* t() should not be used, instead we should use the StringTranslationTrait.
*/
public function test4() {
return t('Test');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExampleClass:: |
public | function | Using \Drupal here is allowed since this class cannot access the container. | |
ExampleClass:: |
public | function | Loading nodes directly is allowed since we cannot access the container. | |
ExampleClass:: |
public | function | Global function is allowed since we cannot access the container. | |
ExampleClass:: |
public | function | t() should not be used, instead we should use the StringTranslationTrait. |