class EntityReferenceSelection

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection
Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection
  2. 8.9.x core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection
  3. 10 core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection
  4. 10 core/lib/Drupal/Core/Entity/Attribute/EntityReferenceSelection.php \Drupal\Core\Entity\Attribute\EntityReferenceSelection

Defines an EntityReferenceSelection attribute for plugin discovery.

Plugin Namespace: Plugin\EntityReferenceSelection

For a working example, see \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection

Hierarchy

Expanded class hierarchy of EntityReferenceSelection

See also

\Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager

\Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface

Plugin API

12 files declare their use of EntityReferenceSelection
AllExceptHostEntity.php in core/modules/system/tests/modules/entity_reference_test/src/Plugin/EntityReferenceSelection/AllExceptHostEntity.php
Broken.php in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
CommentSelection.php in core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php
DefaultSelection.php in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
FileSelection.php in core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php

... See full list

File

core/lib/Drupal/Core/Entity/Attribute/EntityReferenceSelection.php, line 20

Namespace

Drupal\Core\Entity\Attribute
View source
class EntityReferenceSelection extends Plugin {
    
    /**
     * Constructs an EntityReferenceSelection attribute.
     *
     * @param string $id
     *   The plugin ID. There are some implementation bugs that make the plugin
     *   available only if the ID follows a specific pattern. It must be either
     *   identical to group or prefixed with the group. E.g. if the group is "foo"
     *   the ID must be either "foo" or "foo:bar".
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
     *   The human-readable name of the selection plugin.
     * @param string $group
     *   The selection plugin group. This property is used to allow selection
     *   plugins to target a specific entity type while also inheriting the code
     *   of an existing selection plugin. For example, if we want to override the
     *   NodeSelection from the 'default' selection type, we can define the
     *   attribute as follows:
     *   @code
     *   #[EntityReferenceSelection(
     *     id: "default:node_advanced",
     *     entity_types: ["node"],
     *     group: "default",
     *     weight: 5
     *   )]
     *   @endcode
     * @param int $weight
     *   The weight of the plugin in its group. This property is used to select
     *   the "best" plugin within a group.
     * @param string[] $entity_types
     *   (optional) An array of entity types that can be referenced by this
     *   plugin. Defaults to all entity types.
     * @param class-string|null $deriver
     *   (optional) The deriver class.
     */
    public function __construct(string $id, TranslatableMarkup $label, string $group, int $weight, array $entity_types = [], ?string $deriver = NULL) {
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::get public function Gets the value of an attribute. Overrides AttributeInterface::get 7
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass 1
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass 1
AttributeBase::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeInterface::setProvider
EntityReferenceSelection::__construct public function Constructs an EntityReferenceSelection attribute. Overrides Plugin::__construct

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