Skip to content

Commit 6fee80a

Browse files
author
Igor Melnikov
committed
Merge branch 'create-default-hydrator' into develop
2 parents 6bbb305 + 13477dd commit 6fee80a

File tree

113 files changed

+2482
-580
lines changed

Some content is hidden

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

113 files changed

+2482
-580
lines changed

app/code/Magento/Bundle/Model/Product/ReadHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ public function __construct(OptionRepository $optionRepository)
2929
}
3030

3131
/**
32-
* @param string $entityType
3332
* @param object $entity
3433
* @param array $arguments
3534
* @return \Magento\Catalog\Api\Data\ProductInterface
3635
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3736
*/
38-
public function execute($entityType, $entity, $arguments = [])
37+
public function execute($entity, $arguments = [])
3938
{
4039
/** @var $entity \Magento\Catalog\Api\Data\ProductInterface */
4140
if ($entity->getTypeId() != \Magento\Bundle\Model\Product\Type::TYPE_CODE) {

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Bundle\Model\Product;
87

98
use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
10-
use Magento\Framework\EntityManager\MetadataPool;
119
use Magento\Bundle\Api\ProductLinkManagementInterface;
1210
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1311

@@ -16,11 +14,6 @@
1614
*/
1715
class SaveHandler implements ExtensionInterface
1816
{
19-
/**
20-
* @var MetadataPool
21-
*/
22-
protected $metadataPool;
23-
2417
/**
2518
* @var OptionRepository
2619
*/
@@ -33,27 +26,23 @@ class SaveHandler implements ExtensionInterface
3326

3427
/**
3528
* @param OptionRepository $optionRepository
36-
* @param MetadataPool $metadataPool
3729
* @param ProductLinkManagementInterface $productLinkManagement
3830
*/
3931
public function __construct(
4032
OptionRepository $optionRepository,
41-
MetadataPool $metadataPool,
4233
ProductLinkManagementInterface $productLinkManagement
4334
) {
4435
$this->optionRepository = $optionRepository;
45-
$this->metadataPool = $metadataPool;
4636
$this->productLinkManagement = $productLinkManagement;
4737
}
4838

4939
/**
50-
* @param string $entityType
5140
* @param object $entity
5241
* @param array $arguments
5342
* @return \Magento\Catalog\Api\Data\ProductInterface|object
5443
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5544
*/
56-
public function execute($entityType, $entity, $arguments = [])
45+
public function execute($entity, $arguments = [])
5746
{
5847
$bundleProductOptions = $entity->getExtensionAttributes()->getBundleProductOptions();
5948
if ($entity->getTypeId() !== 'bundle' || empty($bundleProductOptions)) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1111

1212
/**
13-
* Create handler for catalog product gallery.
13+
* Create handler for catalog product gallery
14+
*
1415
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1516
*/
1617
class CreateHandler implements ExtensionInterface
@@ -85,7 +86,6 @@ public function __construct(
8586
}
8687

8788
/**
88-
* @param string $entityType
8989
* @param object $product
9090
* @param array $arguments
9191
* @return object
@@ -94,7 +94,7 @@ public function __construct(
9494
* @SuppressWarnings(PHPMD.NPathComplexity)
9595
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9696
*/
97-
public function execute($entityType, $product, $arguments = [])
97+
public function execute($product, $arguments = [])
9898
{
9999
$attrCode = $this->getAttribute()->getAttributeCode();
100100

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ public function __construct(
4040
}
4141

4242
/**
43-
* @param string $entityType
4443
* @param object $entity
4544
* @param array $arguments
4645
* @return object
4746
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4847
*/
49-
public function execute($entityType, $entity, $arguments = [])
48+
public function execute($entity, $arguments = [])
5049
{
5150
$value = [];
5251
$value['images'] = [];

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,27 @@
1616
*/
1717
class ReadHandler implements ExtensionInterface
1818
{
19-
/**
20-
* @var OptionFactory
21-
*/
22-
protected $optionFactory;
23-
24-
/**
25-
* @var MetadataPool
26-
*/
27-
protected $metadataPool;
28-
2919
/**
3020
* @var ProductCustomOptionRepositoryInterface
3121
*/
3222
protected $optionRepository;
3323

3424
/**
3525
* @param ProductCustomOptionRepositoryInterface $optionRepository
36-
* @param MetadataPool $metadataPool
37-
* @param OptionFactory $optionFactory
3826
*/
3927
public function __construct(
40-
ProductCustomOptionRepositoryInterface $optionRepository,
41-
MetadataPool $metadataPool,
42-
OptionFactory $optionFactory
28+
ProductCustomOptionRepositoryInterface $optionRepository
4329
) {
4430
$this->optionRepository = $optionRepository;
45-
$this->metadataPool = $metadataPool;
46-
$this->optionFactory = $optionFactory;
4731
}
4832

4933
/**
50-
* @param string $entityType
5134
* @param object $entity
5235
* @param array $arguments
5336
* @return \Magento\Catalog\Api\Data\ProductInterface|object
5437
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5538
*/
56-
public function execute($entityType, $entity, $arguments = [])
39+
public function execute($entity, $arguments = [])
5740
{
5841
$options = [];
5942
/** @var $entity \Magento\Catalog\Api\Data\ProductInterface */

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Catalog\Model\Product\Option;
87

98
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
10-
use Magento\Framework\EntityManager\MetadataPool;
119
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1210

1311
/**
1412
* Class SaveHandler
1513
*/
1614
class SaveHandler implements ExtensionInterface
1715
{
18-
/**
19-
* @var MetadataPool
20-
*/
21-
protected $metadataPool;
22-
2316
/**
2417
* @var OptionRepository
2518
*/
@@ -30,21 +23,18 @@ class SaveHandler implements ExtensionInterface
3023
* @param MetadataPool $metadataPool
3124
*/
3225
public function __construct(
33-
OptionRepository $optionRepository,
34-
MetadataPool $metadataPool
26+
OptionRepository $optionRepository
3527
) {
3628
$this->optionRepository = $optionRepository;
37-
$this->metadataPool = $metadataPool;
3829
}
3930

4031
/**
41-
* @param string $entityType
4232
* @param object $entity
4333
* @param array $arguments
4434
* @return \Magento\Catalog\Api\Data\ProductInterface|object
4535
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4636
*/
47-
public function execute($entityType, $entity, $arguments = [])
37+
public function execute($entity, $arguments = [])
4838
{
4939
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
5040
foreach ($this->optionRepository->getProductOptions($entity) as $option) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ public function load($object, $entityId, $attributes = [])
993993
{
994994
$this->_attributes = [];
995995
$this->loadAttributesMetadata($attributes);
996-
$object = $this->getEntityManager()->load($object, $entityId, CategoryInterface::class, []);
997-
if (!$this->getEntityManager()->has($object, \Magento\Catalog\Api\Data\CategoryInterface::class, [])) {
996+
$object = $this->getEntityManager()->load($object, $entityId);
997+
if (!$this->getEntityManager()->has($object)) {
998998
$object->isObjectNew(true);
999999
}
10001000
return $this;
@@ -1005,7 +1005,7 @@ public function load($object, $entityId, $attributes = [])
10051005
*/
10061006
public function delete($object)
10071007
{
1008-
$this->getEntityManager()->delete($object, CategoryInterface::class, []);
1008+
$this->getEntityManager()->delete($object);
10091009
$this->_eventManager->dispatch(
10101010
'catalog_category_delete_after_done',
10111011
['product' => $object]
@@ -1022,7 +1022,7 @@ public function delete($object)
10221022
*/
10231023
public function save(\Magento\Framework\Model\AbstractModel $object)
10241024
{
1025-
$this->getEntityManager()->save($object, CategoryInterface::class, []);
1025+
$this->getEntityManager()->save($object);
10261026
return $this;
10271027
}
10281028

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ protected function _afterSave(\Magento\Framework\DataObject $product)
299299
*/
300300
public function delete($object)
301301
{
302-
$this->getEntityManager()->delete($object, \Magento\Catalog\Api\Data\ProductInterface::class, []);
302+
$this->getEntityManager()->delete($object);
303303
$this->eventManager->dispatch(
304304
'catalog_product_delete_after_done',
305305
['product' => $object]
@@ -651,7 +651,7 @@ public function validate($object)
651651
public function load($object, $entityId, $attributes = [])
652652
{
653653
$this->loadAttributesMetadata($attributes);
654-
$this->getEntityManager()->load($object, $entityId, \Magento\Catalog\Api\Data\ProductInterface::class, []);
654+
$this->getEntityManager()->load($object, $entityId);
655655
return $this;
656656
}
657657

@@ -691,7 +691,7 @@ protected function evaluateDelete($object, $id, $connection)
691691
*/
692692
public function save(\Magento\Framework\Model\AbstractModel $object)
693693
{
694-
$this->getEntityManager()->save($object, ProductInterface::class, []);
694+
$this->getEntityManager()->save($object);
695695
return $this;
696696
}
697697

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,14 @@
570570
<item name="store" xsi:type="string">Magento\Store\Model\StoreScopeProvider</item>
571571
</item>
572572
</item>
573+
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="array">
574+
<item name="entityTableName" xsi:type="string">catalog_category_entity</item>
575+
<item name="eavEntityType" xsi:type="string">catalog_category</item>
576+
<item name="identifierField" xsi:type="string">entity_id</item>
577+
<item name="entityContext" xsi:type="array">
578+
<item name="store" xsi:type="string">Magento\Store\Model\StoreScopeProvider</item>
579+
</item>
580+
</item>
573581
</argument>
574582
</arguments>
575583
</type>
@@ -712,19 +720,12 @@
712720
<argument name="attributePersistor" xsi:type="object">Magento\Catalog\Model\ResourceModel\AttributePersistor</argument>
713721
</arguments>
714722
</virtualType>
715-
<type name="Magento\Framework\Model\ResourceModel\Db\ExtensionPool">
723+
<type name="Magento\Framework\EntityManager\HydratorPool">
716724
<arguments>
717-
<argument name="extensionActions" xsi:type="array">
718-
<item name="eav" xsi:type="array">
719-
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="array">
720-
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
721-
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
722-
</item>
723-
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array">
724-
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
725-
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
726-
</item>
727-
</item>
725+
<argument name="hydrators" xsi:type="array">
726+
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
727+
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
728+
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
728729
</argument>
729730
</arguments>
730731
</type>

app/code/Magento/Catalog/etc/events.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,19 @@
3636
<event name="magento_catalog_api_data_categoryinterface_load_after">
3737
<observer name="legacy_category_load_after" instance="Magento\Framework\EntityManager\Observer\AfterEntityLoad" />
3838
</event>
39+
<event name="magento_catalog_api_data_categorytreeinterface_save_before">
40+
<observer name="legacy_categorytree_save_before" instance="Magento\Framework\EntityManager\Observer\BeforeEntitySave" />
41+
</event>
42+
<event name="magento_catalog_api_data_categorytreeinterface_save_after">
43+
<observer name="legacy_categorytree_save_after" instance="Magento\Framework\EntityManager\Observer\AfterEntitySave" />
44+
</event>
45+
<event name="magento_catalog_api_data_categorytreeinterface_delete_before">
46+
<observer name="legacy_categorytree_delete_before" instance="Magento\Framework\EntityManager\Observer\BeforeEntityDelete" />
47+
</event>
48+
<event name="magento_catalog_api_data_categorytreeinterface_delete_after">
49+
<observer name="legacy_categorytree_delete_after" instance="Magento\Framework\EntityManager\Observer\AfterEntityDelete" />
50+
</event>
51+
<event name="magento_catalog_api_data_categorytreeinterface_load_after">
52+
<observer name="legacy_categorytree_load_after" instance="Magento\Framework\EntityManager\Observer\AfterEntityLoad" />
53+
</event>
3954
</config>

0 commit comments

Comments
 (0)