public function EntityViewDisplay::getRenderer in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php \Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer()
Gets the renderer plugin for a field (e.g. widget, formatter).
Parameters
string $field_name: The field name.
Return value
\Drupal\Core\Field\PluginSettingsInterface|null A widget or formatter plugin or NULL if the field does not exist.
Overrides EntityDisplayInterface::getRenderer
1 call to EntityViewDisplay::getRenderer()
- EntityViewDisplay::buildMultiple in core/
lib/ Drupal/ Core/ Entity/ Entity/ EntityViewDisplay.php - Builds a renderable array for the components of a set of entities.
File
- core/
lib/ Drupal/ Core/ Entity/ Entity/ EntityViewDisplay.php, line 194 - Contains \Drupal\Core\Entity\Entity\EntityViewDisplay.
Class
- EntityViewDisplay
- Configuration entity that contains display options for all components of a rendered entity in a given view mode.
Namespace
Drupal\Core\Entity\EntityCode
public function getRenderer($field_name) {
if (isset($this->plugins[$field_name])) {
return $this->plugins[$field_name];
}
// Instantiate the formatter object from the stored display properties.
if (($configuration = $this
->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this
->getFieldDefinition($field_name))) {
$formatter = $this->pluginManager
->getInstance(array(
'field_definition' => $definition,
'view_mode' => $this->originalMode,
// No need to prepare, defaults have been merged in setComponent().
'prepare' => FALSE,
'configuration' => $configuration,
));
}
else {
$formatter = NULL;
}
// Persist the formatter object.
$this->plugins[$field_name] = $formatter;
return $formatter;
}