EntityReferenceSelection.php

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

Namespace

Drupal\Core\Entity\Annotation

File

core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php

View source
<?php

namespace Drupal\Core\Entity\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
 * Defines an EntityReferenceSelection plugin annotation object.
 *
 * Plugin Namespace: Plugin\EntityReferenceSelection
 *
 * For a working example, see
 * \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection
 *
 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface
 * @see plugin_api
 *
 * @Annotation
 */
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.
     *
     * @var \Drupal\Core\Annotation\Translation
     *
     * @ingroup plugin_translatable
     */
    public $label;
    
    /**
     * The selection plugin group.
     *
     * @var string
     * 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
     */
    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;

}

Classes

Title Deprecated Summary
EntityReferenceSelection Defines an EntityReferenceSelection plugin annotation object.

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