From 787564d0ef317c830a1eff2c6d4f3a5fe90f2a03 Mon Sep 17 00:00:00 2001
From: Yu Tang <ytang1@ebay.com>
Date: Wed, 6 May 2015 15:23:08 -0500
Subject: [PATCH] MAGETWO-32409: GiftCard Integration API

    - Change data_objects.xml to service_data_attributes.xml
---
 .../Magento/CatalogInventory/etc/data_object.xml | 12 ------------
 .../etc/service_data_attributes.xml              |  4 ----
 ...ta_object.xml => service_data_attributes.xml} |  6 +++---
 ...ta_object.xml => service_data_attributes.xml} |  6 +++---
 .../Reflection/AttributeTypeResolver.php         |  2 +-
 .../Test/Unit/AttributeTypeResolverTest.php      | 16 ++++++++++++++--
 6 files changed, 21 insertions(+), 25 deletions(-)
 delete mode 100644 app/code/Magento/CatalogInventory/etc/data_object.xml
 rename app/code/Magento/ConfigurableProduct/etc/{data_object.xml => service_data_attributes.xml} (75%)
 rename app/code/Magento/Downloadable/etc/{data_object.xml => service_data_attributes.xml} (76%)

diff --git a/app/code/Magento/CatalogInventory/etc/data_object.xml b/app/code/Magento/CatalogInventory/etc/data_object.xml
deleted file mode 100644
index 05dcea3df63..00000000000
--- a/app/code/Magento/CatalogInventory/etc/data_object.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Copyright © 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
--->
-<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
-    <custom_attributes for="Magento\Catalog\Api\Data\ProductInterface">
-        <attribute code="stock_item" type="Magento\CatalogInventory\Api\Data\StockItemInterface" />
-    </custom_attributes>
-</config>
diff --git a/app/code/Magento/CatalogInventory/etc/service_data_attributes.xml b/app/code/Magento/CatalogInventory/etc/service_data_attributes.xml
index 577b4678c42..587b98b401a 100644
--- a/app/code/Magento/CatalogInventory/etc/service_data_attributes.xml
+++ b/app/code/Magento/CatalogInventory/etc/service_data_attributes.xml
@@ -7,14 +7,10 @@
 -->
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
     <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
-    <!--
-        Once this is merged with the branch with the CatalogInventory integration, need to make sure the permission
-        below is actually used.
         <attribute code="stock_item" type="Magento\CatalogInventory\Api\Data\StockItemInterface">
             <resources>
                 <resource ref="Magento_CatalogInventory::cataloginventory"/>
             </resources>
         </attribute>
-    -->
     </extension_attributes>
 </config>
diff --git a/app/code/Magento/ConfigurableProduct/etc/data_object.xml b/app/code/Magento/ConfigurableProduct/etc/service_data_attributes.xml
similarity index 75%
rename from app/code/Magento/ConfigurableProduct/etc/data_object.xml
rename to app/code/Magento/ConfigurableProduct/etc/service_data_attributes.xml
index f8572079b7b..74edcdbf65a 100644
--- a/app/code/Magento/ConfigurableProduct/etc/data_object.xml
+++ b/app/code/Magento/ConfigurableProduct/etc/service_data_attributes.xml
@@ -5,9 +5,9 @@
  * See COPYING.txt for license details.
  */
 -->
-<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
-    <custom_attributes for="Magento\Catalog\Api\Data\ProductInterface">
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
+    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
         <attribute code="configurable_product_options" type="Magento\ConfigurableProduct\Api\Data\OptionInterface[]" />
         <attribute code="configurable_product_links" type="int[]" />
-    </custom_attributes>
+    </extension_attributes>
 </config>
diff --git a/app/code/Magento/Downloadable/etc/data_object.xml b/app/code/Magento/Downloadable/etc/service_data_attributes.xml
similarity index 76%
rename from app/code/Magento/Downloadable/etc/data_object.xml
rename to app/code/Magento/Downloadable/etc/service_data_attributes.xml
index dd9f05c1a28..80cc1cb0abf 100644
--- a/app/code/Magento/Downloadable/etc/data_object.xml
+++ b/app/code/Magento/Downloadable/etc/service_data_attributes.xml
@@ -5,9 +5,9 @@
  * See COPYING.txt for license details.
  */
 -->
-<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
-    <custom_attributes for="Magento\Catalog\Api\Data\ProductInterface">
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
+    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
         <attribute code="downloadable_product_links" type="Magento\Downloadable\Api\Data\LinkInterface[]" />
         <attribute code="downloadable_product_samples" type="Magento\Downloadable\Api\Data\SampleInterface[]" />
-    </custom_attributes>
+    </extension_attributes>
 </config>
diff --git a/lib/internal/Magento/Framework/Reflection/AttributeTypeResolver.php b/lib/internal/Magento/Framework/Reflection/AttributeTypeResolver.php
index 8552cba5a5d..6824dca09e5 100644
--- a/lib/internal/Magento/Framework/Reflection/AttributeTypeResolver.php
+++ b/lib/internal/Magento/Framework/Reflection/AttributeTypeResolver.php
@@ -44,7 +44,7 @@ class AttributeTypeResolver implements AttributeTypeResolverInterface
         $config = isset($data[$context]) ? $data[$context] : [];
         $output = get_class($value);
         if (isset($config[$attributeCode])) {
-            $type = $config[$attributeCode];
+            $type = $config[$attributeCode]['type'];
             $output = $this->typeProcessor->getArrayItemType($type);
             if (!(class_exists($output) || interface_exists($output))) {
                 throw new \LogicException(
diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php
index 8391d464348..68902f38513 100644
--- a/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php
+++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php
@@ -62,7 +62,13 @@ class AttributeTypeResolverTest extends \PHPUnit_Framework_TestCase
         $code = 'some_code';
         $value = new \stdClass();
         $context = '\Some\Class';
-        $config = ['Some\Class' => ['some_code' => '\Magento\Framework\Object']];
+        $config = [
+            'Some\Class' => [
+                'some_code' => [
+                    'type' => '\Magento\Framework\Object',
+                ],
+            ]
+        ];
 
         $this->typeProcessor->expects($this->once())
             ->method('getArrayItemType')
@@ -82,7 +88,13 @@ class AttributeTypeResolverTest extends \PHPUnit_Framework_TestCase
         $code = 'some_code';
         $value = new \stdClass();
         $context = '\Some\Class';
-        $config = ['Some\Class' => ['some_code' => '\Some\Class']];
+        $config = [
+            'Some\Class' => [
+                'some_code' => [
+                    'type' => '\Some\Class',
+                ]
+            ]
+        ];
 
         $this->typeProcessor->expects($this->once())
             ->method('getArrayItemType')
-- 
GitLab