interface SelectionWithAutocreateInterface (View source)

Interface for Selection plugins that support newly created entities.

Methods

createNewEntity(string $entity_type_id, string $bundle, string $label, int $uid)

Creates a new entity object that can be used as a valid reference.

validateReferenceableNewEntities(array $entities)

Validates which newly created entities can be referenced.

Details

EntityInterface createNewEntity(string $entity_type_id, string $bundle, string $label, int $uid)

Creates a new entity object that can be used as a valid reference.

Parameters

string $entity_type_id

The entity type ID.

string $bundle

The bundle name.

string $label

The entity label.

int $uid

The entity owner ID, if the entity type supports it.

Return Value

EntityInterface

An unsaved entity object.

EntityInterface[] validateReferenceableNewEntities(array $entities)

Validates which newly created entities can be referenced.

This method should replicate the logic implemented by \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::validateReferenceableEntities(), but applied to newly created entities that have not been saved yet.

Parameters

array $entities

An array of entities to check.

Return Value

EntityInterface[]

The incoming $entities parameter, filtered for valid entities. Array keys are preserved.