entity_views_handler_relationship.inc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @file
  4. * Contains the entity_views_handler_relationship class.
  5. */
  6. /**
  7. * Relationship handler for data selection tables.
  8. *
  9. * This handler may only be used in conjunction with data selection based Views
  10. * tables or other base tables using a query plugin that supports data
  11. * selection.
  12. *
  13. * @see entity_views_field_definition()
  14. * @ingroup views_field_handlers
  15. */
  16. class entity_views_handler_relationship extends views_handler_relationship {
  17. /**
  18. * Slightly modify the options form provided by the parent handler.
  19. */
  20. public function options_form(&$form, &$form_state) {
  21. parent::options_form($form, $form_state);
  22. // This won't work with data selector-based relationships, as we only
  23. // inspect those *after* the results are known.
  24. $form['required']['#access'] = FALSE;
  25. // Notify the user of our restrictions regarding lists of entities, if
  26. // appropriate.
  27. if (!empty($this->definition['multiple'])) {
  28. $form['multiple_note'] = array(
  29. '#markup' => t('<strong>Note:</strong> This is a multi-valued relationship, which is currently not supported. ' .
  30. 'Only the first related entity will be shown.'),
  31. '#weight' => -5,
  32. );
  33. }
  34. }
  35. /**
  36. * Called to implement a relationship in a query.
  37. *
  38. * As we don't add any data to the query itself, we don't have to do anything
  39. * here. Views just don't thinks we have been called unless we set our
  40. * $alias property. Otherwise, this override is just here to keep PHP from
  41. * blowing up by calling inexistent methods on the query plugin.
  42. */
  43. public function query() {
  44. $this->alias = $this->options['id'];
  45. }
  46. }