public function EntityDisplayBase::removeComponent

Sets a component to be hidden.

Parameters

string $name: The name of the component.

Return value

\Drupal\entity\Plugin\Core\Entity\EntityDisplay The EntityDisplay object.

Overrides EntityDisplayBaseInterface::removeComponent

File

drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php, line 244
Contains \Drupal\entity\EntityDisplayBase.

Class

EntityDisplayBase
Base class for config entity types that store configuration for entity forms and displays.

Namespace

Drupal\entity

Code

public function removeComponent($name) {
  $extra_fields = field_info_extra_fields($this->targetEntityType, $this->bundle, $this->displayContext);
  if (isset($extra_fields[$name])) {

    // 'Extra fields' are exposed in hooks and can appear at any given time.
    // Therefore we store extra fields that are explicitly being hidden, so
    // that we can differenciate with those that are simply not configured
    // yet.
    $this->content[$name] = array(
      'visible' => FALSE,
    );
  }
  else {
    unset($this->content[$name]);
    unset($this->plugins[$name]);
  }
  return $this;
}