Sets the display options for a component.
string $name: The name of the component.
array $options: The display options.
\Drupal\entity\Plugin\Core\Entity\EntityDisplay The EntityDisplay object.
Overrides EntityDisplayBaseInterface::setComponent
public function setComponent($name, array $options = array()) {
// If no weight specified, make sure the field sinks at the bottom.
if (!isset($options['weight'])) {
$max = $this
->getHighestWeight();
$options['weight'] = isset($max) ? $max + 1 : 0;
}
if ($instance = field_info_instance($this->targetEntityType, $name, $this->bundle)) {
$field = field_info_field($instance['field_name']);
$options = $this->pluginManager
->prepareConfiguration($field['type'], $options);
// Clear the persisted plugin, if any.
unset($this->plugins[$name]);
}
// We always store 'extra fields', whether they are visible or hidden.
$extra_fields = field_info_extra_fields($this->targetEntityType, $this->bundle, $this->displayContext);
if (isset($extra_fields[$name])) {
$options['visible'] = TRUE;
}
$this->content[$name] = $options;
return $this;
}