Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityReferenceSelection / SelectionWithAutocreateInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity\EntityReferenceSelection;
4
5 /**
6  * Interface for Selection plugins that support newly created entities.
7  *
8  * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
9  * @see \Drupal\Core\Entity\Annotation\EntityReferenceSelection
10  * @see plugin_api
11  */
12 interface SelectionWithAutocreateInterface {
13
14   /**
15    * Creates a new entity object that can be used as a valid reference.
16    *
17    * @param string $entity_type_id
18    *   The entity type ID.
19    * @param string $bundle
20    *   The bundle name.
21    * @param string $label
22    *   The entity label.
23    * @param int $uid
24    *   The entity owner ID, if the entity type supports it.
25    *
26    * @return \Drupal\Core\Entity\EntityInterface
27    *   An unsaved entity object.
28    */
29   public function createNewEntity($entity_type_id, $bundle, $label, $uid);
30
31   /**
32    * Validates which newly created entities can be referenced.
33    *
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.
37    *
38    * @param \Drupal\Core\Entity\EntityInterface[] $entities
39    *   An array of entities to check.
40    *
41    * @return \Drupal\Core\Entity\EntityInterface[]
42    *   The incoming $entities parameter, filtered for valid entities. Array keys
43    *   are preserved.
44    */
45   public function validateReferenceableNewEntities(array $entities);
46
47 }