commerce_product_reference.inc 770 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @file
  4. * Contains a CER plugin for Commerce's Product Reference fields.
  5. */
  6. class CerCommerceProductReferenceField extends CerField {
  7. /**
  8. * Implements CerField::getTargetType().
  9. */
  10. public function getTargetType() {
  11. return 'commerce_product';
  12. }
  13. /**
  14. * Overrides CerField::getTargetBundles().
  15. */
  16. public function getTargetBundles() {
  17. // Product reference fields store their referenceable types by instance
  18. // instead of by field, so the $this->settings variable we inherit
  19. // from CerField is useless here.
  20. $instance = field_info_instance($this->entityType, $this->name, $this->bundle);
  21. $types = $instance['settings']['referenceable_types'];
  22. return ($types ? $types : parent::getTargetBundles());
  23. }
  24. }