public function EntityDisplayBase::getComponent

Gets the display options set for a component.

Parameters

string $name: The name of the component.

Return value

array|null The display options for the component, or NULL if the component is not displayed.

Overrides EntityDisplayBaseInterface::getComponent

2 calls to EntityDisplayBase::getComponent()
EntityDisplay::getFormatter in drupal/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php
Returns the Formatter plugin for a field.
EntityFormDisplay::getWidget in drupal/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php
Returns the Widget plugin for a field.

File

drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php, line 177
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 getComponent($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])) {

    // If we have explicit settings, return an array or NULL depending on
    // visibility.
    if (isset($this->content[$name])) {
      if ($this->content[$name]['visible']) {
        return array(
          'weight' => $this->content[$name]['weight'],
        );
      }
      else {
        return NULL;
      }
    }

    // If no explicit settings for the extra field, look at the default
    // visibility in its definition.
    $definition = $extra_fields[$name];
    if (!isset($definition['visible']) || $definition['visible'] == TRUE) {
      return array(
        'weight' => $definition['weight'],
      );
    }
    else {
      return NULL;
    }
  }
  if (isset($this->content[$name])) {
    return $this->content[$name];
  }
}