Skip to content

Commit 6e46c0d

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'origin/MAGETWO-36000-Join-Processors' into MAGETWO-36000-Join-Processors
2 parents 9566fbd + c24966e commit 6e46c0d

File tree

19 files changed

+230
-65
lines changed

19 files changed

+230
-65
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,21 @@ public function getValues();
201201
* @return $this
202202
*/
203203
public function setValues(array $values = null);
204+
205+
/**
206+
* Retrieve existing extension attributes object or create a new one.
207+
*
208+
* @return \Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface|null
209+
*/
210+
public function getExtensionAttributes();
211+
212+
/**
213+
* Set an extension attributes object.
214+
*
215+
* @param \Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface $extensionAttributes
216+
* @return $this
217+
*/
218+
public function setExtensionAttributes(
219+
\Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface $extensionAttributes
220+
);
204221
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,4 +852,26 @@ public function setValues(array $values = null)
852852
return $this;
853853
}
854854
//@codeCoverageIgnoreEnd
855+
856+
/**
857+
* {@inheritdoc}
858+
*
859+
* @return \Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface|null
860+
*/
861+
public function getExtensionAttributes()
862+
{
863+
return $this->_getExtensionAttributes();
864+
}
865+
866+
/**
867+
* {@inheritdoc}
868+
*
869+
* @param \Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface $extensionAttributes
870+
* @return $this
871+
*/
872+
public function setExtensionAttributes(
873+
\Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface $extensionAttributes
874+
) {
875+
return $this->_setExtensionAttributes($extensionAttributes);
876+
}
855877
}

app/code/Magento/Tax/Model/Calculation/RateRepository.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface
6565
*/
6666
protected $resourceModel;
6767

68+
/**
69+
* @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
70+
*/
71+
protected $joinProcessor;
72+
6873
/**
6974
* @param Converter $converter
7075
* @param RateRegistry $rateRegistry
@@ -73,6 +78,7 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface
7378
* @param CountryFactory $countryFactory
7479
* @param RegionFactory $regionFactory
7580
* @param \Magento\Tax\Model\Resource\Calculation\Rate $rateResource
81+
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
7682
*/
7783
public function __construct(
7884
Converter $converter,
@@ -81,7 +87,8 @@ public function __construct(
8187
RateFactory $rateFactory,
8288
CountryFactory $countryFactory,
8389
RegionFactory $regionFactory,
84-
\Magento\Tax\Model\Resource\Calculation\Rate $rateResource
90+
\Magento\Tax\Model\Resource\Calculation\Rate $rateResource,
91+
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
8592
) {
8693
$this->converter = $converter;
8794
$this->rateRegistry = $rateRegistry;
@@ -90,6 +97,7 @@ public function __construct(
9097
$this->countryFactory = $countryFactory;
9198
$this->regionFactory = $regionFactory;
9299
$this->resourceModel = $rateResource;
100+
$this->joinProcessor = $joinProcessor;
93101
}
94102

95103
/**
@@ -146,6 +154,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
146154
{
147155
/** @var \Magento\Tax\Model\Resource\Calculation\Rate\Collection $collection */
148156
$collection = $this->rateFactory->create()->getCollection();
157+
$this->joinProcessor->process($collection);
149158
$collection->joinRegionTable();
150159

151160
//Add filters from root filter group to the collection

app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase
5959
*/
6060
private $rateResourceMock;
6161

62+
/**
63+
* @var \PHPUnit_Framework_MockObject_MockObject
64+
*/
65+
private $joinProcessorMock;
66+
6267
public function setUp()
6368
{
6469
$this->rateConverterMock = $this->getMock(
@@ -117,14 +122,22 @@ public function setUp()
117122
'',
118123
false
119124
);
125+
$this->joinProcessorMock = $this->getMock(
126+
'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface',
127+
[],
128+
[],
129+
'',
130+
false
131+
);
120132
$this->model = new RateRepository(
121133
$this->rateConverterMock,
122134
$this->rateRegistryMock,
123135
$this->searchResultFactory,
124136
$this->rateFactoryMock,
125137
$this->countryFactoryMock,
126138
$this->regionFactoryMock,
127-
$this->rateResourceMock
139+
$this->rateResourceMock,
140+
$this->joinProcessorMock
128141
);
129142
}
130143

@@ -256,6 +269,8 @@ public function testGetList()
256269
->willReturnSelf();
257270
$this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock);
258271

272+
$this->joinProcessorMock->expects($this->once())->method('process')->with($collectionMock);
273+
259274
$this->model->getList($searchCriteriaMock);
260275
}
261276

@@ -402,6 +417,8 @@ public function testGetListWhenFilterGroupExists()
402417
->willReturnSelf();
403418
$this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock);
404419

420+
$this->joinProcessorMock->expects($this->once())->method('process')->with($collectionMock);
421+
405422
$this->model->getList($searchCriteriaMock);
406423
}
407424

app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
5252
*/
5353
protected $extensionAttributesJoinProcessorMock;
5454

55-
/**
5655
/**
5756
* @return void
5857
*/

app/code/Magento/User/Model/UserInterface.php renamed to app/code/Magento/User/Api/Data/UserInterface.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\User\Model;
6+
namespace Magento\User\Api\Data;
77

88
/**
99
* Admin user interface.
@@ -14,119 +14,119 @@ interface UserInterface
1414
{
1515
/**
1616
* Get ID.
17-
*
17+
*
1818
* @return int
1919
*/
2020
public function getId();
21-
21+
2222
/**
2323
* Set ID.
24-
*
24+
*
2525
* @param int $id
2626
* @return $this
2727
*/
2828
public function setId($id);
29-
29+
3030
/**
3131
* Get first name.
32-
*
32+
*
3333
* @return string
3434
*/
3535
public function getFirstName();
36-
36+
3737
/**
3838
* Set first name.
39-
*
39+
*
4040
* @param string $firstName
4141
* @return $this
4242
*/
4343
public function setFirstName($firstName);
44-
44+
4545
/**
4646
* Get last name.
47-
*
47+
*
4848
* @return string
4949
*/
5050
public function getLastName();
51-
51+
5252
/**
5353
* Set last name.
54-
*
54+
*
5555
* @param string $lastName
5656
* @return $this
5757
*/
5858
public function setLastName($lastName);
59-
59+
6060
/**
6161
* Get email.
62-
*
62+
*
6363
* @return string
6464
*/
6565
public function getEmail();
66-
66+
6767
/**
6868
* Set email.
69-
*
69+
*
7070
* @param string $email
7171
* @return $this
7272
*/
7373
public function setEmail($email);
74-
74+
7575
/**
7676
* Get user name.
77-
*
77+
*
7878
* @return string
7979
*/
8080
public function getUserName();
81-
81+
8282
/**
8383
* Set user name.
84-
*
84+
*
8585
* @param string $userName
8686
* @return $this
8787
*/
8888
public function setUserName($userName);
89-
89+
9090
/**
9191
* Get password or password hash.
92-
*
92+
*
9393
* @return string
9494
*/
9595
public function getPassword();
96-
96+
9797
/**
9898
* Set password or password hash.
99-
*
99+
*
100100
* @param string $password
101101
* @return $this
102102
*/
103103
public function setPassword($password);
104-
104+
105105
/**
106106
* Get user record creation date.
107-
*
107+
*
108108
* @return string
109109
*/
110110
public function getCreated();
111-
111+
112112
/**
113113
* Set user record creation date.
114-
*
114+
*
115115
* @param string $created
116116
* @return $this
117117
*/
118118
public function setCreated($created);
119-
119+
120120
/**
121121
* Get user record modification date.
122-
*
122+
*
123123
* @return string
124124
*/
125125
public function getModified();
126-
126+
127127
/**
128128
* Set user record modification date.
129-
*
129+
*
130130
* @param string $modified
131131
* @return $this
132132
*/

app/code/Magento/User/Model/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Backend\Model\Auth\Credential\StorageInterface;
99
use Magento\Framework\Model\AbstractModel;
1010
use Magento\Framework\Exception\AuthenticationException;
11+
use Magento\User\Api\Data\UserInterface;
1112

1213
/**
1314
* Admin user model

app/code/Magento/User/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
<type name="Magento\Authorization\Model\Role">
1515
<plugin name="updateRoleUsersAcl" type="Magento\User\Model\Plugin\AuthorizationRole" sortOrder="20"/>
1616
</type>
17-
<preference for="Magento\User\Model\UserInterface" type="Magento\User\Model\User" />
17+
<preference for="Magento\User\Api\Data\UserInterface" type="Magento\User\Model\User" />
1818
</config>

dev/tests/api-functional/_files/Magento/TestJoinDirectives/Model/TestRepository.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@
1111
/**
1212
* Model TestRepository
1313
*/
14-
class TestRepository implements TestRepositoryInterface
14+
class TestRepository implements TestRepositoryInterface
1515
{
1616
/**
17-
* @var \Magento\Quote\Model\Resource\Quote\Collection
17+
* @var \Magento\Quote\Model\Resource\Quote\CollectionFactory
1818
*/
19-
protected $quoteCollection;
19+
private $quoteCollectionFactory;
2020

2121
/**
2222
* @var \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory
2323
*/
24-
protected $searchResultsDataFactory;
24+
private $searchResultsDataFactory;
2525

2626
/**
2727
* @var JoinProcessorInterface
2828
*/
2929
private $extensionAttributesJoinProcessor;
3030

3131
/**
32-
* @param \Magento\Quote\Model\Resource\Quote\Collection $quoteCollection
32+
* @param \Magento\Quote\Model\Resource\Quote\CollectionFactory $quoteCollectionFactory
3333
* @param \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory
3434
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
3535
*/
3636
public function __construct(
37-
\Magento\Quote\Model\Resource\Quote\Collection $quoteCollection,
37+
\Magento\Quote\Model\Resource\Quote\CollectionFactory $quoteCollectionFactory,
3838
\Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory,
3939
JoinProcessorInterface $extensionAttributesJoinProcessor
4040
) {
41+
$this->quoteCollectionFactory = $quoteCollectionFactory;
4142
$this->searchResultsDataFactory = $searchResultsDataFactory;
42-
$this->quoteCollection = $quoteCollection;
4343
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
4444
}
4545

@@ -48,10 +48,11 @@ public function __construct(
4848
*/
4949
public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
5050
{
51+
$quoteCollection = $this->quoteCollectionFactory->create();
52+
$this->extensionAttributesJoinProcessor->process($quoteCollection);
5153
$searchData = $this->searchResultsDataFactory->create();
5254
$searchData->setSearchCriteria($searchCriteria);
53-
$this->extensionAttributesJoinProcessor->process($this->quoteCollection);
54-
$searchData->setItems($this->quoteCollection->getItems());
55+
$searchData->setItems($quoteCollection->getItems());
5556
return $searchData;
5657
}
5758
}

0 commit comments

Comments
 (0)