W3cubDocs

/Drupal 8

public function EntityDisplayBase::setComponent

public EntityDisplayBase::setComponent($name, array $options = array())

Sets the display options for a component.

Parameters

string $name: The name of the component.

array $options: The display options.

Return value

$this

Overrides EntityDisplayInterface::setComponent

File

core/lib/Drupal/Core/Entity/EntityDisplayBase.php, line 322

Class

EntityDisplayBase
Provides a common base class for entity view and form displays.

Namespace

Drupal\Core\Entity

Code

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;
  }

  // For a field, fill in default options.
  if ($field_definition = $this->getFieldDefinition($name)) {
    $options = $this->pluginManager->prepareConfiguration($field_definition->getType(), $options);
  }

  // Ensure we always have an empty settings and array.
  $options += ['settings' => [], 'third_party_settings' => []];

  $this->content[$name] = $options;
  unset($this->hidden[$name]);
  unset($this->plugins[$name]);

  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityDisplayBase.php/function/EntityDisplayBase::setComponent/8.1.x