3 namespace Drupal\Core\Entity\EntityReferenceSelection;
6 * Interface for Selection plugins that support newly created entities.
8 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
9 * @see \Drupal\Core\Entity\Annotation\EntityReferenceSelection
12 interface SelectionWithAutocreateInterface {
15 * Creates a new entity object that can be used as a valid reference.
17 * @param string $entity_type_id
19 * @param string $bundle
21 * @param string $label
24 * The entity owner ID, if the entity type supports it.
26 * @return \Drupal\Core\Entity\EntityInterface
27 * An unsaved entity object.
29 public function createNewEntity($entity_type_id, $bundle, $label, $uid);
32 * Validates which newly created entities can be referenced.
34 * This method should replicate the logic implemented by
35 * \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::validateReferenceableEntities(),
36 * but applied to newly created entities that have not been saved yet.
38 * @param \Drupal\Core\Entity\EntityInterface[] $entities
39 * An array of entities to check.
41 * @return \Drupal\Core\Entity\EntityInterface[]
42 * The incoming $entities parameter, filtered for valid entities. Array keys
45 public function validateReferenceableNewEntities(array $entities);