public function EntityDisplayBase::getHighestWeight

Returns the highest weight of the components in the display.

Return value

int|null The highest weight of the components in the display, or NULL if the display is empty.

Overrides EntityDisplayBaseInterface::getHighestWeight

1 call to EntityDisplayBase::getHighestWeight()
EntityDisplayBase::setComponent in drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
Sets the display options for a component.

File

drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php, line 266
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 getHighestWeight() {
  $weights = array();

  // Collect weights for the components in the display.
  foreach ($this->content as $options) {
    if (isset($options['weight'])) {
      $weights[] = $options['weight'];
    }
  }

  // Let other modules feedback about their own additions.
  $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $this->targetEntityType, $this->bundle, $this->displayContext, $this->mode));
  return $weights ? max($weights) : NULL;
}