Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection
  2. 9 core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php \Drupal\Core\Entity\Annotation\EntityReferenceSelection

Defines an EntityReferenceSelection plugin annotation object.

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

Related topics

File

core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php, line 21

Namespace

Drupal\Core\Entity\Annotation
View source
class EntityReferenceSelection extends Plugin {

  /**
   * 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".
   *
   * @var string
   */
  public $id;

  /**
   * The human-readable name of the selection plugin.
   *
   * @ingroup plugin_translatable
   *
   * @var \Drupal\Core\Annotation\Translation
   */
  public $label;

  /**
   * 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 annotation of a new plugin as follows:
   * @code
   * id = "default:node_advanced",
   * entity_types = {"node"},
   * group = "default",
   * weight = 5
   * @endcode
   *
   * @var string
   */
  public $group;

  /**
   * An array of entity types that can be referenced by this plugin.
   *
   * Defaults to all entity types.
   *
   * This property is optional and it does not need to be declared.
   *
   * @var array
   */
  public $entity_types = [];

  /**
   * The weight of the plugin in its group.
   *
   * This property is used to select the "best" plugin within a group.
   *
   * @var int
   */
  public $weight;

}

Members

Name Modifiers Typesort descending Description Overrides
Plugin::__construct public function Constructs a Plugin object. 3
Plugin::parse protected function Parses an annotation into its definition.
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 6
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider 1
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass 1
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass 1
EntityReferenceSelection::$id public property The plugin ID.
EntityReferenceSelection::$label public property The human-readable name of the selection plugin.
EntityReferenceSelection::$group public property The selection plugin group.
EntityReferenceSelection::$entity_types public property An array of entity types that can be referenced by this plugin.
EntityReferenceSelection::$weight public property The weight of the plugin in its group.
Plugin::$definition protected property The plugin definition read from the class annotation. 1