You are here

function hook_field_info_max_weight in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/field.api.php \hook_field_info_max_weight()

Returns the maximum weight for the entity components handled by the module.

Field API takes care of fields and 'extra_fields'. This hook is intended for third-party modules adding other entity components (e.g. field_group).

Parameters

string $entity_type: The type of entity; e.g. 'node' or 'user'.

string $bundle: The bundle name.

string $context: The context for which the maximum weight is requested. Either 'form' or 'display'.

string $context_mode: The view or form mode name.

Return value

int The maximum weight of the entity's components, or NULL if no components were found.

Related topics

1 invocation of hook_field_info_max_weight()
EntityDisplayBase::getHighestWeight in core/lib/Drupal/Core/Entity/EntityDisplayBase.php
Gets the highest weight of the components in the display.

File

core/modules/field/field.api.php, line 254

Code

function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode) {
  $weights = array();
  foreach (my_module_entity_additions($entity_type, $bundle, $context, $context_mode) as $addition) {
    $weights[] = $addition['weight'];
  }
  return $weights ? max($weights) : NULL;
}