protected function ProductAttributeFieldManager::getHighestWeight in Commerce Core 8.2
Gets the highest weight of the attribute field components in the display.
Parameters
\Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display: The form display.
Return value
int The highest weight of the components in the display.
1 call to ProductAttributeFieldManager::getHighestWeight()
- ProductAttributeFieldManager::createField in modules/
product/ src/ ProductAttributeFieldManager.php - Creates an attribute field for the given attribute.
File
- modules/
product/ src/ ProductAttributeFieldManager.php, line 272
Class
- ProductAttributeFieldManager
- Default implementation of the ProductAttributeFieldManagerInterface.
Namespace
Drupal\commerce_productCode
protected function getHighestWeight(EntityFormDisplayInterface $form_display) {
$field_names = array_keys($this
->getFieldDefinitions($form_display
->getTargetBundle()));
$weights = [];
foreach ($field_names as $field_name) {
if ($component = $form_display
->getComponent($field_name)) {
$weights[] = $component['weight'];
}
}
return $weights ? max($weights) : 0;
}