public function ExampleWithDependencyInjection::view in Extra Field 8
Same name and namespace in other branches
- 8.2 modules/extra_field_example/src/Plugin/ExtraField/Display/ExampleWithDependencyInjection.php \Drupal\extra_field_example\Plugin\ExtraField\Display\ExampleWithDependencyInjection::view()
Builds a renderable array for the field.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The field's host entity.
Return value
array Renderable array.
Overrides ExtraFieldDisplayInterface::view
File
- modules/
extra_field_example/ src/ Plugin/ ExtraField/ Display/ ExampleWithDependencyInjection.php, line 65
Class
- ExampleWithDependencyInjection
- Example Extra field Display.
Namespace
Drupal\extra_field_example\Plugin\ExtraField\DisplayCode
public function view(ContentEntityInterface $entity) {
// Some output to demonstrate the injected service.
$scheme = $this->currentRequest
->getScheme();
$elements = [
'#markup' => $this
->t('Request scheme: @scheme', [
'@scheme' => $scheme,
]),
];
return $elements;
}