Last active
August 29, 2015 14:17
-
-
Save xuxucode/2a1c44a322aa13e3ef68 to your computer and use it in GitHub Desktop.
Add support for commerce_product_reference, commerce_line_item and field_collection to RestfulEntityBase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugins/restful/RestfulEntityBase.php b/plugins/restful/RestfulEntityBase.php | |
index 4155075..4c29f96 100644 | |
--- a/plugins/restful/RestfulEntityBase.php | |
+++ b/plugins/restful/RestfulEntityBase.php | |
@@ -460,6 +460,15 @@ abstract class RestfulEntityBase extends \RestfulDataProviderEFQ implements \Res | |
elseif ($field['type'] == 'taxonomy_term_reference') { | |
return 'taxonomy_term'; | |
} | |
+ elseif ($field['type'] == 'commerce_product_reference') { | |
+ return 'commerce_product'; | |
+ } | |
+ elseif ($field['type'] == 'commerce_line_item_reference') { | |
+ return 'commerce_line_item'; | |
+ } | |
+ elseif ($field['type'] == 'field_collection') { | |
+ return 'field_collection_item'; | |
+ } | |
throw new \RestfulException(format_string('Field @property is not an entity reference or taxonomy reference field.', $params)); | |
} | |
@@ -715,6 +724,8 @@ abstract class RestfulEntityBase extends \RestfulDataProviderEFQ implements \Res | |
switch ($field_info['type']) { | |
case 'entityreference': | |
case 'taxonomy_term_reference': | |
+ case 'commerce_product_reference': | |
+ case 'commerce_line_item_reference': | |
return $this->propertyValuesPreprocessReference($property_name, $value, $field_info, $public_field_name); | |
case 'text': | |
@@ -1384,12 +1395,14 @@ abstract class RestfulEntityBase extends \RestfulDataProviderEFQ implements \Res | |
$field_types = array( | |
'entityreference', | |
'taxonomy_term_reference', | |
+ 'commerce_product_reference', | |
); | |
$widget_types = array( | |
'taxonomy_autocomplete', | |
'entityreference_autocomplete', | |
'entityreference_autocomplete_tags', | |
+ 'commerce_product_reference_autocomplete', | |
); | |
return !in_array($field['type'], $field_types) || !in_array($instance['widget']['type'], $widget_types); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment