Skip to content
Snippets Groups Projects
Commit adaeb66a authored by Edouard Cunibil's avatar Edouard Cunibil
Browse files

Issue #3525775: [2.0.x] Cannot use computed entity reference bundle field in a component

parent 10351c35
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,34 @@ use Drupal\Component\Plugin\PluginBase;
*/
class EntityReferenceFieldPropertyDerivableContextDeriver extends EntityFieldSourceDeriverBase {
/**
* {@inheritdoc}
*/
protected function getDerivativeDefinitionsForEntityBundleField(string $entity_type_id, string $bundle, string $field_name, array $base_plugin_derivative): void {
// Check if the field is an entity reference field and has no storage.
// Fields with storage are handled by
// `self::getDerivativeDefinitionsForEntityStorageFieldProperty()`.
if (
!empty($this->entityFieldsMetadata[$entity_type_id]["field_storages"][$field_name]) ||
empty($this->entityFieldsMetadata[$entity_type_id]["bundles"][$bundle]["fields"][$field_name]["entity_reference"])) {
return;
}
$id = implode(PluginBase::DERIVATIVE_SEPARATOR, [
$entity_type_id,
$bundle,
$field_name,
"target_id",
]);
$this->derivatives[$id] = array_merge(
$base_plugin_derivative,
[
"id" => $id,
"label" => $this->t("Field prop: entity"),
"context_requirements" => array_merge($base_plugin_derivative["context_requirements"], ["field_granularity:item"]),
"tags" => array_merge($base_plugin_derivative["tags"], ["xxx"]),
]);
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment