interface SelectionWithAutocreateInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionWithAutocreateInterface.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionWithAutocreateInterface.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface
  3. 10 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionWithAutocreateInterface.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface

Interface for Selection plugins that support newly created entities.

Hierarchy

Expanded class hierarchy of SelectionWithAutocreateInterface

All classes that implement SelectionWithAutocreateInterface

See also

\Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager

\Drupal\Core\Entity\Annotation\EntityReferenceSelection

Plugin API

3 files declare their use of SelectionWithAutocreateInterface
DefaultSelection.php in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
EntityAutocomplete.php in core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
ValidReferenceConstraintValidator.php in core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraintValidator.php

File

core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionWithAutocreateInterface.php, line 12

Namespace

Drupal\Core\Entity\EntityReferenceSelection
View source
interface SelectionWithAutocreateInterface {
    
    /**
     * Creates a new entity object that can be used as a valid reference.
     *
     * @param string $entity_type_id
     *   The entity type ID.
     * @param string $bundle
     *   The bundle name.
     * @param string $label
     *   The entity label.
     * @param int $uid
     *   The entity owner ID, if the entity type supports it.
     *
     * @return \Drupal\Core\Entity\EntityInterface
     *   An unsaved entity object.
     */
    public function createNewEntity($entity_type_id, $bundle, $label, $uid);
    
    /**
     * 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.
     *
     * @param \Drupal\Core\Entity\EntityInterface[] $entities
     *   An array of entities to check.
     *
     * @return \Drupal\Core\Entity\EntityInterface[]
     *   The incoming $entities parameter, filtered for valid entities. Array keys
     *   are preserved.
     */
    public function validateReferenceableNewEntities(array $entities);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
SelectionWithAutocreateInterface::createNewEntity public function Creates a new entity object that can be used as a valid reference. 1
SelectionWithAutocreateInterface::validateReferenceableNewEntities public function Validates which newly created entities can be referenced. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.