Problem/Motivation
Drupal allows to declare computed fields per bundle using the hook_entity_bundle_field_info.
For example:
/**
* Implements hook_entity_bundle_field_info().
*/
function mymodule_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
$computed_fields = [];
if ($entity_type->id() === 'node') {
if ($bundle === 'production') {
$computed_fields['prod_all_pictures'] = BaseFieldDefinition::create('entity_reference')
->setLabel('Toutes les images')
->setComputed(TRUE)
->setTranslatable(FALSE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setSetting('target_type', 'media')
->setClass('\Drupal\mymodule\Plugin\ComputedField\ProductionPictures')
->setDisplayConfigurable('view', TRUE);
}
}
return $computed_fields;
}
A field declared this way cannot be used in components because the \Drupal\ui_patterns\Plugin\Derivative\EntityReferenceFieldPropertyDerivableContextDeriver deriver does not implement the getDerivativeDefinitionsForEntityBundleField() method to handle those.
Proposed resolution
Implement the method ;)
Comments
Comment #3
duaelfrThere is a proposal.
Patch attached for composer.
Comment #4
pdureau commentedHi Mikael, I know you are busy but it is part of your initial scope. Don't hesitate to assign to Christian if necessary.
Comment #5
duaelfr(Sorry for the above commits. It was a rebase mistake.)
Comment #6
pdureau commentedComment #8
just_like_good_vibes