if (!isset($this->content[$name]) && !isset($this->hidden[$name])) {
// Extra fields are visible by default unless they explicitly say so.
if (!isset($definition['visible']) || $definition['visible'] == TRUE) {
- $this->content[$name] = [
- 'weight' => $definition['weight']
- ];
+ $this->setComponent($name, [
+ 'weight' => $definition['weight'],
+ ]);
}
else {
- $this->hidden[$name] = TRUE;
+ $this->removeComponent($name);
}
}
// Ensure extra fields have a 'region'.
}
if (!empty($options['region']) && $options['region'] === 'hidden') {
- $this->hidden[$name] = TRUE;
+ $this->removeComponent($name);
}
elseif ($options) {
$options += ['region' => $default_region];
- $this->content[$name] = $this->pluginManager->prepareConfiguration($definition->getType(), $options);
+ $this->setComponent($name, $options);
}
// Note: (base) fields that do not specify display options are not
// tracked in the display at all, in order to avoid cluttering the
/**
* {@inheritdoc}
*/
- public function preSave(EntityStorageInterface $storage, $update = TRUE) {
+ public function preSave(EntityStorageInterface $storage) {
// Ensure that a region is set on each component.
foreach ($this->getComponents() as $name => $component) {
$this->handleHiddenType($name, $component);
ksort($this->content);
ksort($this->hidden);
- parent::preSave($storage, $update);
+ parent::preSave($storage);
}
/**
/**
* Determines if a field has options for a given display.
*
- * @param FieldDefinitionInterface $definition
+ * @param \Drupal\Core\Field\FieldDefinitionInterface $definition
* A field definition.
* @return array|null
*/