EntityReferenceSelection.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Drupal\Core\Entity\Annotation;
  3. use Drupal\Component\Annotation\Plugin;
  4. /**
  5. * Defines an EntityReferenceSelection plugin annotation object.
  6. *
  7. * Plugin Namespace: Plugin\EntityReferenceSelection
  8. *
  9. * For a working example, see
  10. * \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection
  11. *
  12. * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
  13. * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface
  14. * @see plugin_api
  15. *
  16. * @Annotation
  17. */
  18. class EntityReferenceSelection extends Plugin {
  19. /**
  20. * The plugin ID.
  21. *
  22. * There are some implementation bugs that make the plugin available only if
  23. * the ID follows a specific pattern. It must be either identical to group or
  24. * prefixed with the group. E.g. if the group is "foo" the ID must be either
  25. * "foo" or "foo:bar".
  26. *
  27. * @var string
  28. */
  29. public $id;
  30. /**
  31. * The human-readable name of the selection plugin.
  32. *
  33. * @ingroup plugin_translatable
  34. *
  35. * @var \Drupal\Core\Annotation\Translation
  36. */
  37. public $label;
  38. /**
  39. * The selection plugin group.
  40. *
  41. * This property is used to allow selection plugins to target a specific
  42. * entity type while also inheriting the code of an existing selection plugin.
  43. * For example, if we want to override the NodeSelection from the 'default'
  44. * selection type, we can define the annotation of a new plugin as follows:
  45. * @code
  46. * id = "default:node_advanced",
  47. * entity_types = {"node"},
  48. * group = "default",
  49. * weight = 5
  50. * @endcode
  51. *
  52. * @var string
  53. */
  54. public $group;
  55. /**
  56. * An array of entity types that can be referenced by this plugin. Defaults to
  57. * all entity types.
  58. *
  59. * @var array (optional)
  60. */
  61. public $entity_types = [];
  62. /**
  63. * The weight of the plugin in its group.
  64. *
  65. * This property is used to select the "best" plugin within a group.
  66. *
  67. * @var int
  68. */
  69. public $weight;
  70. }