Skip to content

Commit fd9337c

Browse files
author
Eugene Tulika
committed
Merge pull request #84 from magento-fearless-kiwis/develop
[FearlessKiwis] Removing Immutability from Customer and Tax Modules
2 parents 209cfbe + 28ab691 commit fd9337c

File tree

240 files changed

+6273
-2603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+6273
-2603
lines changed

app/code/Magento/Bundle/Model/Source/Option/Type.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Magento\Bundle\Model\Source\Option;
1010

11-
use Magento\Framework\Api\AttributeDataBuilder;
11+
use Magento\Framework\Api\AttributeValueFactory;
1212
use Magento\Framework\Api\MetadataServiceInterface;
1313

1414
class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements
@@ -24,7 +24,7 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements
2424
* @param \Magento\Framework\Model\Context $context
2525
* @param \Magento\Framework\Registry $registry
2626
* @param MetadataServiceInterface $metadataService
27-
* @param AttributeDataBuilder $customAttributeBuilder
27+
* @param AttributeValueFactory $customAttributeFactory
2828
* @param array $options
2929
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
3030
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
@@ -34,7 +34,7 @@ public function __construct(
3434
\Magento\Framework\Model\Context $context,
3535
\Magento\Framework\Registry $registry,
3636
MetadataServiceInterface $metadataService,
37-
AttributeDataBuilder $customAttributeBuilder,
37+
AttributeValueFactory $customAttributeFactory,
3838
array $options,
3939
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
4040
\Magento\Framework\Data\Collection\Db $resourceCollection = null,
@@ -45,7 +45,7 @@ public function __construct(
4545
$context,
4646
$registry,
4747
$metadataService,
48-
$customAttributeBuilder,
48+
$customAttributeFactory,
4949
$resource,
5050
$resourceCollection,
5151
$data

app/code/Magento/Catalog/Api/Data/ProductAttributeDataBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ProductAttributeDataBuilder extends \Magento\Framework\Api\Builder
1919
/**
2020
* @param ObjectFactory $objectFactory
2121
* @param MetadataServiceInterface $metadataService
22-
* @param \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder
22+
* @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory
2323
* @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor
2424
* @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor
2525
* @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory
@@ -29,7 +29,7 @@ class ProductAttributeDataBuilder extends \Magento\Framework\Api\Builder
2929
public function __construct(
3030
ObjectFactory $objectFactory,
3131
MetadataServiceInterface $metadataService,
32-
\Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder,
32+
\Magento\Framework\Api\AttributeValueFactory $attributeValueFactory,
3333
\Magento\Framework\Reflection\DataObjectProcessor $objectProcessor,
3434
\Magento\Framework\Reflection\TypeProcessor $typeProcessor,
3535
\Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory,
@@ -39,7 +39,7 @@ public function __construct(
3939
parent::__construct(
4040
$objectFactory,
4141
$metadataService,
42-
$attributeValueBuilder,
42+
$attributeValueFactory,
4343
$objectProcessor,
4444
$typeProcessor,
4545
$dataBuilderFactory,

app/code/Magento/Catalog/Helper/Data.php

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
110110
protected $_templateFilterFactory;
111111

112112
/**
113-
* Tax class key builder
113+
* Tax class key factory
114114
*
115-
* @var \Magento\Tax\Api\Data\TaxClassKeyDataBuilder
115+
* @var \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory
116116
*/
117-
protected $_taxClassKeyBuilder;
117+
protected $_taxClassKeyFactory;
118118

119119
/**
120120
* Tax helper
@@ -124,18 +124,18 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
124124
protected $_taxConfig;
125125

126126
/**
127-
* Quote details builder
127+
* Quote details factory
128128
*
129-
* @var \Magento\Tax\Api\Data\QuoteDetailsDataBuilder
129+
* @var \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory
130130
*/
131-
protected $_quoteDetailsBuilder;
131+
protected $_quoteDetailsFactory;
132132

133133
/**
134-
* Quote details item builder
134+
* Quote details item factory
135135
*
136-
* @var \Magento\Tax\Api\Data\QuoteDetailsItemDataBuilder
136+
* @var \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory
137137
*/
138-
protected $_quoteDetailsItemBuilder;
138+
protected $_quoteDetailsItemFactory;
139139

140140
/**
141141
* @var CustomerSession
@@ -177,10 +177,10 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
177177
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
178178
* @param \Magento\Catalog\Model\Template\Filter\Factory $templateFilterFactory
179179
* @param string $templateFilterModel
180-
* @param \Magento\Tax\Api\Data\TaxClassKeyDataBuilder $taxClassKeyBuilder
180+
* @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyFactory
181181
* @param Config $taxConfig
182-
* @param \Magento\Tax\Api\Data\QuoteDetailsDataBuilder $quoteDetailsBuilder
183-
* @param \Magento\Tax\Api\Data\QuoteDetailsItemDataBuilder $quoteDetailsItemBuilder
182+
* @param \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsFactory
183+
* @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemFactory
184184
* @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
185185
* @param CustomerSession $customerSession
186186
* @param PriceCurrencyInterface $priceCurrency
@@ -199,10 +199,10 @@ public function __construct(
199199
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
200200
\Magento\Catalog\Model\Template\Filter\Factory $templateFilterFactory,
201201
$templateFilterModel,
202-
\Magento\Tax\Api\Data\TaxClassKeyDataBuilder $taxClassKeyBuilder,
202+
\Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyFactory,
203203
\Magento\Tax\Model\Config $taxConfig,
204-
\Magento\Tax\Api\Data\QuoteDetailsDataBuilder $quoteDetailsBuilder,
205-
\Magento\Tax\Api\Data\QuoteDetailsItemDataBuilder $quoteDetailsItemBuilder,
204+
\Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsFactory,
205+
\Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemFactory,
206206
\Magento\Tax\Api\TaxCalculationInterface $taxCalculationService,
207207
CustomerSession $customerSession,
208208
PriceCurrencyInterface $priceCurrency,
@@ -218,10 +218,10 @@ public function __construct(
218218
$this->_scopeConfig = $scopeConfig;
219219
$this->_coreRegistry = $coreRegistry;
220220
$this->_templateFilterModel = $templateFilterModel;
221-
$this->_taxClassKeyBuilder = $taxClassKeyBuilder;
221+
$this->_taxClassKeyFactory = $taxClassKeyFactory;
222222
$this->_taxConfig = $taxConfig;
223-
$this->_quoteDetailsBuilder = $quoteDetailsBuilder;
224-
$this->_quoteDetailsItemBuilder = $quoteDetailsItemBuilder;
223+
$this->_quoteDetailsFactory = $quoteDetailsFactory;
224+
$this->_quoteDetailsItemFactory = $quoteDetailsItemFactory;
225225
$this->_taxCalculationService = $taxCalculationService;
226226
$this->_customerSession = $customerSession;
227227
$this->priceCurrency = $priceCurrency;
@@ -501,27 +501,29 @@ public function getTaxPrice(
501501
$billingAddressDataObject = $billingAddress->getDataModel();
502502
}
503503

504-
$item = $this->_quoteDetailsItemBuilder->setQuantity(1)
504+
$taxClassKey = $this->_taxClassKeyFactory->create();
505+
$taxClassKey->setType(TaxClassKeyInterface::TYPE_ID)
506+
->setValue($product->getTaxClassId());
507+
508+
$customerTaxClassKey = $this->_taxClassKeyFactory->create();
509+
$customerTaxClassKey->setType(TaxClassKeyInterface::TYPE_ID)
510+
->setValue($ctc);
511+
512+
$item = $this->_quoteDetailsItemFactory->create();
513+
$item->setQuantity(1)
505514
->setCode($product->getSku())
506515
->setShortDescription($product->getShortDescription())
507-
->setTaxClassKey(
508-
$this->_taxClassKeyBuilder->setType(TaxClassKeyInterface::TYPE_ID)
509-
->setValue($product->getTaxClassId())
510-
->create()
511-
)->setTaxIncluded($priceIncludesTax)
516+
->setTaxClassKey($taxClassKey)
517+
->setIsTaxIncluded($priceIncludesTax)
512518
->setType('product')
513-
->setUnitPrice($price)
514-
->create();
515-
$quoteDetails = $this->_quoteDetailsBuilder
516-
->setShippingAddress($shippingAddressDataObject)
519+
->setUnitPrice($price);
520+
521+
$quoteDetails = $this->_quoteDetailsFactory->create();
522+
$quoteDetails->setShippingAddress($shippingAddressDataObject)
517523
->setBillingAddress($billingAddressDataObject)
518-
->setCustomerTaxClassKey(
519-
$this->_taxClassKeyBuilder->setType(TaxClassKeyInterface::TYPE_ID)
520-
->setValue($ctc)
521-
->create()
522-
)->setItems([$item])
523-
->setCustomerId($this->_customerSession->getCustomerId())
524-
->create();
524+
->setCustomerTaxClassKey($customerTaxClassKey)
525+
->setItems([$item])
526+
->setCustomerId($this->_customerSession->getCustomerId());
525527

526528
$storeId = null;
527529
if ($store) {

app/code/Magento/Catalog/Model/AbstractModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8-
use Magento\Framework\Api\AttributeDataBuilder;
8+
use Magento\Framework\Api\AttributeValueFactory;
99

1010
/**
1111
* Abstract model for catalog entities
@@ -63,7 +63,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible
6363
* @param \Magento\Framework\Model\Context $context
6464
* @param \Magento\Framework\Registry $registry
6565
* @param \Magento\Framework\Api\MetadataServiceInterface $metadataService
66-
* @param AttributeDataBuilder $customAttributeBuilder
66+
* @param AttributeValueFactory $customAttributeFactory
6767
* @param \Magento\Framework\Store\StoreManagerInterface $storeManager
6868
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
6969
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
@@ -73,7 +73,7 @@ public function __construct(
7373
\Magento\Framework\Model\Context $context,
7474
\Magento\Framework\Registry $registry,
7575
\Magento\Framework\Api\MetadataServiceInterface $metadataService,
76-
AttributeDataBuilder $customAttributeBuilder,
76+
AttributeValueFactory $customAttributeFactory,
7777
\Magento\Framework\Store\StoreManagerInterface $storeManager,
7878
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
7979
\Magento\Framework\Data\Collection\Db $resourceCollection = null,
@@ -84,7 +84,7 @@ public function __construct(
8484
$context,
8585
$registry,
8686
$metadataService,
87-
$customAttributeBuilder,
87+
$customAttributeFactory,
8888
$resource,
8989
$resourceCollection,
9090
$data

app/code/Magento/Catalog/Model/Category.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
99
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
10-
use Magento\Framework\Api\AttributeDataBuilder;
10+
use Magento\Framework\Api\AttributeValueFactory;
1111
use Magento\Framework\Convert\ConvertArray;
1212
use Magento\Framework\Exception\NoSuchEntityException;
1313
use Magento\Framework\Profiler;
@@ -177,7 +177,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
177177
* @param \Magento\Framework\Model\Context $context
178178
* @param \Magento\Framework\Registry $registry
179179
* @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService
180-
* @param AttributeDataBuilder $customAttributeBuilder
180+
* @param AttributeValueFactory $customAttributeFactory
181181
* @param \Magento\Framework\Store\StoreManagerInterface $storeManager
182182
* @param Resource\Category\Tree $categoryTreeResource
183183
* @param Resource\Category\TreeFactory $categoryTreeFactory
@@ -200,7 +200,7 @@ public function __construct(
200200
\Magento\Framework\Model\Context $context,
201201
\Magento\Framework\Registry $registry,
202202
\Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService,
203-
AttributeDataBuilder $customAttributeBuilder,
203+
AttributeValueFactory $customAttributeFactory,
204204
\Magento\Framework\Store\StoreManagerInterface $storeManager,
205205
\Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource,
206206
\Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory,
@@ -234,7 +234,7 @@ public function __construct(
234234
$context,
235235
$registry,
236236
$metadataService,
237-
$customAttributeBuilder,
237+
$customAttributeFactory,
238238
$storeManager,
239239
$resource,
240240
$resourceCollection,

app/code/Magento/Catalog/Model/Entity/Attribute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Catalog\Model\Entity;
77

88
use Magento\Catalog\Model\Attribute\LockValidatorInterface;
9-
use Magento\Framework\Api\AttributeDataBuilder;
9+
use Magento\Framework\Api\AttributeValueFactory;
1010

1111
/**
1212
* Product attribute extension with event dispatching
@@ -72,7 +72,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
7272
* @param \Magento\Framework\Model\Context $context
7373
* @param \Magento\Framework\Registry $registry
7474
* @param \Magento\Framework\Api\MetadataServiceInterface $metadataService
75-
* @param AttributeDataBuilder $customAttributeBuilder
75+
* @param AttributeValueFactory $customAttributeFactory
7676
* @param \Magento\Core\Helper\Data $coreData
7777
* @param \Magento\Eav\Model\Config $eavConfig
7878
* @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory
@@ -93,7 +93,7 @@ public function __construct(
9393
\Magento\Framework\Model\Context $context,
9494
\Magento\Framework\Registry $registry,
9595
\Magento\Framework\Api\MetadataServiceInterface $metadataService,
96-
AttributeDataBuilder $customAttributeBuilder,
96+
AttributeValueFactory $customAttributeFactory,
9797
\Magento\Core\Helper\Data $coreData,
9898
\Magento\Eav\Model\Config $eavConfig,
9999
\Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory,
@@ -114,7 +114,7 @@ public function __construct(
114114
$context,
115115
$registry,
116116
$metadataService,
117-
$customAttributeBuilder,
117+
$customAttributeFactory,
118118
$coreData,
119119
$eavConfig,
120120
$eavTypeFactory,

app/code/Magento/Catalog/Model/Product.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
99
use Magento\Catalog\Api\Data\ProductInterface;
10-
use Magento\Framework\Api\AttributeDataBuilder;
10+
use Magento\Framework\Api\AttributeValueFactory;
1111
use Magento\Framework\App\Filesystem\DirectoryList;
1212
use Magento\Framework\Object\IdentityInterface;
1313
use Magento\Framework\Pricing\Object\SaleableInterface;
@@ -242,7 +242,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
242242
* @param \Magento\Framework\Model\Context $context
243243
* @param \Magento\Framework\Registry $registry
244244
* @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService
245-
* @param AttributeDataBuilder $customAttributeBuilder
245+
* @param AttributeValueFactory $customAttributeFactory
246246
* @param \Magento\Framework\Store\StoreManagerInterface $storeManager
247247
* @param Product\Url $url
248248
* @param Product\Link $productLink
@@ -273,7 +273,7 @@ public function __construct(
273273
\Magento\Framework\Model\Context $context,
274274
\Magento\Framework\Registry $registry,
275275
\Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService,
276-
AttributeDataBuilder $customAttributeBuilder,
276+
AttributeValueFactory $customAttributeFactory,
277277
\Magento\Framework\Store\StoreManagerInterface $storeManager,
278278
Product\Url $url,
279279
Product\Link $productLink,
@@ -321,7 +321,7 @@ public function __construct(
321321
$context,
322322
$registry,
323323
$metadataService,
324-
$customAttributeBuilder,
324+
$customAttributeFactory,
325325
$storeManager,
326326
$resource,
327327
$resourceCollection,

app/code/Magento/Catalog/Model/Product/Attribute/Group.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
namespace Magento\Catalog\Model\Product\Attribute;
88

9-
use Magento\Framework\Api\AttributeDataBuilder;
9+
use Magento\Framework\Api\AttributeValueFactory;
1010

1111
class Group extends \Magento\Eav\Model\Entity\Attribute\Group
1212
{
@@ -21,7 +21,7 @@ class Group extends \Magento\Eav\Model\Entity\Attribute\Group
2121
* @param \Magento\Framework\Model\Context $context
2222
* @param \Magento\Framework\Registry $registry
2323
* @param \Magento\Framework\Api\MetadataServiceInterface $metadataService
24-
* @param AttributeDataBuilder $customAttributeBuilder
24+
* @param AttributeValueFactory $customAttributeFactory
2525
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
2626
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
2727
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
@@ -31,7 +31,7 @@ public function __construct(
3131
\Magento\Framework\Model\Context $context,
3232
\Magento\Framework\Registry $registry,
3333
\Magento\Framework\Api\MetadataServiceInterface $metadataService,
34-
AttributeDataBuilder $customAttributeBuilder,
34+
AttributeValueFactory $customAttributeFactory,
3535
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory,
3636
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
3737
\Magento\Framework\Data\Collection\Db $resourceCollection = null,
@@ -42,7 +42,7 @@ public function __construct(
4242
$context,
4343
$registry,
4444
$metadataService,
45-
$customAttributeBuilder,
45+
$customAttributeFactory,
4646
$resource,
4747
$resourceCollection,
4848
$data

0 commit comments

Comments
 (0)