public function EntityDisplayBase::getHighestWeight

public EntityDisplayBase::getHighestWeight()

Gets 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 EntityDisplayInterface::getHighestWeight

File

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

Class

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

Namespace

Drupal\Core\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, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', array($this->targetEntityType, $this->bundle, $this->displayContext, $this->mode)));

  return $weights ? max($weights) : NULL;
}

© 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::getHighestWeight/8.1.x