Skip to content

Commit 2365286

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-95990' into 2.2-develop-pr11
2 parents f286e17 + 101c16c commit 2365286

File tree

2 files changed

+186
-93
lines changed

2 files changed

+186
-93
lines changed

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,80 @@
77
namespace Magento\Customer\Model\ResourceModel;
88

99
use Magento\Customer\Api\CustomerMetadataInterface;
10-
use Magento\Customer\Model\Delegation\Data\NewOperation;
10+
use Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory;
11+
use Magento\Framework\Api\ExtensibleDataObjectConverter;
12+
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
13+
use Magento\Customer\Model\CustomerFactory;
14+
use Magento\Customer\Model\CustomerRegistry;
15+
use Magento\Customer\Model\Data\CustomerSecureFactory;
1116
use Magento\Customer\Model\Customer\NotificationStorage;
17+
use Magento\Customer\Model\Delegation\Data\NewOperation;
18+
use Magento\Customer\Api\CustomerRepositoryInterface;
1219
use Magento\Framework\Api\DataObjectHelper;
1320
use Magento\Framework\Api\ImageProcessorInterface;
1421
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
1522
use Magento\Framework\Api\SearchCriteriaInterface;
23+
use Magento\Framework\Api\Search\FilterGroup;
24+
use Magento\Framework\Event\ManagerInterface;
1625
use Magento\Customer\Model\Delegation\Storage as DelegatedStorage;
1726
use Magento\Framework\App\ObjectManager;
27+
use Magento\Store\Model\StoreManagerInterface;
1828

1929
/**
2030
* Customer repository.
31+
*
2132
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2233
* @SuppressWarnings(PHPMD.TooManyFields)
2334
*/
24-
class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInterface
35+
class CustomerRepository implements CustomerRepositoryInterface
2536
{
2637
/**
27-
* @var \Magento\Customer\Model\CustomerFactory
38+
* @var CustomerFactory
2839
*/
2940
protected $customerFactory;
3041

3142
/**
32-
* @var \Magento\Customer\Model\Data\CustomerSecureFactory
43+
* @var CustomerSecureFactory
3344
*/
3445
protected $customerSecureFactory;
3546

3647
/**
37-
* @var \Magento\Customer\Model\CustomerRegistry
48+
* @var CustomerRegistry
3849
*/
3950
protected $customerRegistry;
4051

4152
/**
42-
* @var \Magento\Customer\Model\ResourceModel\AddressRepository
53+
* @var AddressRepository
4354
*/
4455
protected $addressRepository;
4556

4657
/**
47-
* @var \Magento\Customer\Model\ResourceModel\Customer
58+
* @var Customer
4859
*/
4960
protected $customerResourceModel;
5061

5162
/**
52-
* @var \Magento\Customer\Api\CustomerMetadataInterface
63+
* @var CustomerMetadataInterface
5364
*/
5465
protected $customerMetadata;
5566

5667
/**
57-
* @var \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory
68+
* @var CustomerSearchResultsInterfaceFactory
5869
*/
5970
protected $searchResultsFactory;
6071

6172
/**
62-
* @var \Magento\Framework\Event\ManagerInterface
73+
* @var ManagerInterface
6374
*/
6475
protected $eventManager;
6576

6677
/**
67-
* @var \Magento\Store\Model\StoreManagerInterface
78+
* @var StoreManagerInterface
6879
*/
6980
protected $storeManager;
7081

7182
/**
72-
* @var \Magento\Framework\Api\ExtensibleDataObjectConverter
83+
* @var ExtensibleDataObjectConverter
7384
*/
7485
protected $extensibleDataObjectConverter;
7586

@@ -84,7 +95,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
8495
protected $imageProcessor;
8596

8697
/**
87-
* @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
98+
* @var JoinProcessorInterface
8899
*/
89100
protected $extensionAttributesJoinProcessor;
90101

@@ -104,38 +115,38 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
104115
private $delegatedStorage;
105116

106117
/**
107-
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
108-
* @param \Magento\Customer\Model\Data\CustomerSecureFactory $customerSecureFactory
109-
* @param \Magento\Customer\Model\CustomerRegistry $customerRegistry
110-
* @param \Magento\Customer\Model\ResourceModel\AddressRepository $addressRepository
111-
* @param \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
112-
* @param \Magento\Customer\Api\CustomerMetadataInterface $customerMetadata
113-
* @param \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory $searchResultsFactory
114-
* @param \Magento\Framework\Event\ManagerInterface $eventManager
115-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
116-
* @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
118+
* @param CustomerFactory $customerFactory
119+
* @param CustomerSecureFactory $customerSecureFactory
120+
* @param CustomerRegistry $customerRegistry
121+
* @param AddressRepository $addressRepository
122+
* @param Customer $customerResourceModel
123+
* @param CustomerMetadataInterface $customerMetadata
124+
* @param CustomerSearchResultsInterfaceFactory $searchResultsFactory
125+
* @param ManagerInterface $eventManager
126+
* @param StoreManagerInterface $storeManager
127+
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
117128
* @param DataObjectHelper $dataObjectHelper
118129
* @param ImageProcessorInterface $imageProcessor
119-
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
130+
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
120131
* @param CollectionProcessorInterface $collectionProcessor
121132
* @param NotificationStorage $notificationStorage
122133
* @param DelegatedStorage|null $delegatedStorage
123134
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
124135
*/
125136
public function __construct(
126-
\Magento\Customer\Model\CustomerFactory $customerFactory,
127-
\Magento\Customer\Model\Data\CustomerSecureFactory $customerSecureFactory,
128-
\Magento\Customer\Model\CustomerRegistry $customerRegistry,
129-
\Magento\Customer\Model\ResourceModel\AddressRepository $addressRepository,
130-
\Magento\Customer\Model\ResourceModel\Customer $customerResourceModel,
131-
\Magento\Customer\Api\CustomerMetadataInterface $customerMetadata,
132-
\Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory $searchResultsFactory,
133-
\Magento\Framework\Event\ManagerInterface $eventManager,
134-
\Magento\Store\Model\StoreManagerInterface $storeManager,
135-
\Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
137+
CustomerFactory $customerFactory,
138+
CustomerSecureFactory $customerSecureFactory,
139+
CustomerRegistry $customerRegistry,
140+
AddressRepository $addressRepository,
141+
Customer $customerResourceModel,
142+
CustomerMetadataInterface $customerMetadata,
143+
CustomerSearchResultsInterfaceFactory $searchResultsFactory,
144+
ManagerInterface $eventManager,
145+
StoreManagerInterface $storeManager,
146+
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
136147
DataObjectHelper $dataObjectHelper,
137148
ImageProcessorInterface $imageProcessor,
138-
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
149+
JoinProcessorInterface $extensionAttributesJoinProcessor,
139150
CollectionProcessorInterface $collectionProcessor,
140151
NotificationStorage $notificationStorage,
141152
DelegatedStorage $delegatedStorage = null
@@ -155,8 +166,7 @@ public function __construct(
155166
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
156167
$this->collectionProcessor = $collectionProcessor;
157168
$this->notificationStorage = $notificationStorage;
158-
$this->delegatedStorage = $delegatedStorage
159-
?? ObjectManager::getInstance()->get(DelegatedStorage::class);
169+
$this->delegatedStorage = $delegatedStorage ?? ObjectManager::getInstance()->get(DelegatedStorage::class);
160170
}
161171

162172
/**
@@ -214,15 +224,15 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
214224
$customerModel->setRpToken(null);
215225
$customerModel->setRpTokenCreatedAt(null);
216226
}
217-
if (!array_key_exists('default_billing', $customerArr)
227+
if (!array_key_exists('addresses', $customerArr)
218228
&& null !== $prevCustomerDataArr
219229
&& array_key_exists('default_billing', $prevCustomerDataArr)
220230
) {
221231
$customerModel->setDefaultBilling(
222232
$prevCustomerDataArr['default_billing']
223233
);
224234
}
225-
if (!array_key_exists('default_shipping', $customerArr)
235+
if (!array_key_exists('addresses', $customerArr)
226236
&& null !== $prevCustomerDataArr
227237
&& array_key_exists('default_shipping', $prevCustomerDataArr)
228238
) {
@@ -395,15 +405,12 @@ public function deleteById($customerId)
395405
* Helper function that adds a FilterGroup to the collection.
396406
*
397407
* @deprecated 100.2.0
398-
* @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
399-
* @param \Magento\Customer\Model\ResourceModel\Customer\Collection $collection
408+
* @param FilterGroup $filterGroup
409+
* @param Collection $collection
400410
* @return void
401-
* @throws \Magento\Framework\Exception\InputException
402411
*/
403-
protected function addFilterGroupToCollection(
404-
\Magento\Framework\Api\Search\FilterGroup $filterGroup,
405-
\Magento\Customer\Model\ResourceModel\Customer\Collection $collection
406-
) {
412+
protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
413+
{
407414
$fields = [];
408415
foreach ($filterGroup->getFilters() as $filter) {
409416
$condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';

0 commit comments

Comments
 (0)