function commerce_shipping_commerce_entity_trait_info_alter in Commerce Shipping 8.2
Implements hook_commerce_entity_trait_info_alter().
File
- ./
commerce_shipping.module, line 24 - Provides core shipping functionality.
Code
function commerce_shipping_commerce_entity_trait_info_alter(array &$definitions) {
// Expose the purchasable entity traits for every purchasable entity type.
$entity_types = \Drupal::entityTypeManager()
->getDefinitions();
$entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
return $entity_type
->entityClassImplements(PurchasableEntityInterface::class);
});
$entity_type_ids = array_keys($entity_types);
$definitions['purchasable_entity_dimensions']['entity_types'] = $entity_type_ids;
$definitions['purchasable_entity_shippable']['entity_types'] = $entity_type_ids;
}