abstract.inc

  1. cis7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  2. cis7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  3. cle7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  4. cle7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  5. ecd7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  6. ecd7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  7. elmsmedia7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  8. elmsmedia7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  9. harmony7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  10. harmony7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  11. icor7 sites/all/modules/local_contrib/entityreference_dynamicselect_widget/entityreference/plugins/selection/abstract.inc
  12. icor7 sites/all/modules/local_contrib/entityreference_dynamicselect_widget/entityreference/plugins/behavior/abstract.inc
  13. icor7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  14. icor7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  15. meedjum_blog7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  16. meedjum_blog7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
  17. mooc7 sites/all/modules/ulmus/entityreference/plugins/behavior/abstract.inc
  18. mooc7 sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc

Abstraction of the selection logic of an entity reference field.

Implementations that wish to provide an implementation of this should register it using CTools' plugin system.

Classes

Namesort descending Description
EntityReference_SelectionHandler_Broken A null implementation of EntityReference_SelectionHandler.

Interfaces

Namesort descending Description
EntityReference_SelectionHandler @file Abstraction of the selection logic of an entity reference field.

File

sites/all/modules/ulmus/entityreference/plugins/selection/abstract.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Abstraction of the selection logic of an entity reference field.
  5. *
  6. * Implementations that wish to provide an implementation of this should
  7. * register it using CTools' plugin system.
  8. */
  9. interface EntityReference_SelectionHandler {
  10. /**
  11. * Factory function: create a new instance of this handler for a given field.
  12. *
  13. * @param $field
  14. * A field datastructure.
  15. * @return EntityReferenceHandler
  16. */
  17. public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL);
  18. /**
  19. * Return a list of referencable entities.
  20. *
  21. * @return
  22. * An array of referencable entities, which keys are entity ids and
  23. * values (safe HTML) labels to be displayed to the user.
  24. */
  25. public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
  26. /**
  27. * Count entities that are referencable by a given field.
  28. */
  29. public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS');
  30. /**
  31. * Validate that entities can be referenced by this field.
  32. *
  33. * @return
  34. * An array of entity ids that are valid.
  35. */
  36. public function validateReferencableEntities(array $ids);
  37. /**
  38. * Validate Input from autocomplete widget that has no Id.
  39. *
  40. * @see _entityreference_autocomplete_validate()
  41. *
  42. * @param $input
  43. * Single string from autocomplete widget.
  44. * @param $element
  45. * The form element to set a form error.
  46. * @return
  47. * Value of a matching entity id, or NULL if none.
  48. */
  49. public function validateAutocompleteInput($input, &$element, &$form_state, $form);
  50. /**
  51. * Give the handler a chance to alter the SelectQuery generated by EntityFieldQuery.
  52. */
  53. public function entityFieldQueryAlter(SelectQueryInterface $query);
  54. /**
  55. * Return the label of a given entity.
  56. */
  57. public function getLabel($entity);
  58. /**
  59. * Generate a settings form for this handler.
  60. */
  61. public static function settingsForm($field, $instance);
  62. }
  63. /**
  64. * A null implementation of EntityReference_SelectionHandler.
  65. */
  66. class EntityReference_SelectionHandler_Broken implements EntityReference_SelectionHandler {
  67. public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
  68. return new EntityReference_SelectionHandler_Broken($field, $instance, $entity_type, $entity);
  69. }
  70. protected function __construct($field, $instance) {
  71. $this->field = $field;
  72. $this->instance = $instance;
  73. }
  74. public static function settingsForm($field, $instance) {
  75. $form['selection_handler'] = array(
  76. '#markup' => t('The selected selection handler is broken.'),
  77. );
  78. return $form;
  79. }
  80. public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
  81. return array();
  82. }
  83. public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS') {
  84. return 0;
  85. }
  86. public function validateReferencableEntities(array $ids) {
  87. return array();
  88. }
  89. public function validateAutocompleteInput($input, &$element, &$form_state, $form) {
  90. return NULL;
  91. }
  92. public function entityFieldQueryAlter(SelectQueryInterface $query) {}
  93. public function getLabel($entity) {
  94. return '';
  95. }
  96. }